orztv
commited on
Commit
·
b4dd3ad
1
Parent(s):
e4fbb50
update
Browse files- .env +1 -0
- Dockerfile +30 -23
.env
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
|
Dockerfile
CHANGED
@@ -10,6 +10,20 @@ ARG CACHEBUST=1
|
|
10 |
ARG WEBHOOK_URL=https://你的hf账户名-空间名.hf.space/
|
11 |
ARG POSTGRESDB_PORT=5432
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
# 安装系统依赖
|
14 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
15 |
curl \
|
@@ -36,34 +50,27 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
36 |
&& $VIRTUAL_ENV/bin/pip install --no-cache-dir --upgrade pip pnpm requests yt-dlp \
|
37 |
# 安装 n8n
|
38 |
&& npm install -g n8n@latest \
|
39 |
-
&& npm cache clean --force
|
40 |
-
&& --mount=type=secret,id=POSTGRES_USER,mode=0444,required=true \
|
41 |
-
&& --mount=type=secret,id=POSTGRES_PASSWORD,mode=0444,required=true \
|
42 |
-
&& --mount=type=secret,id=POSTGRES_DB,mode=0444,required=true \
|
43 |
-
&& --mount=type=secret,id=POSTGRESDB_HOST,mode=0444,required=true
|
44 |
|
45 |
-
#
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
DB_POSTGRESDB_DATABASE=$(cat /run/secrets/POSTGRES_DB) \
|
60 |
-
VIRTUAL_ENV=/home/pn/venv \
|
61 |
-
PATH="/home/pn/venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH"
|
62 |
|
63 |
# 创建工作目录
|
64 |
WORKDIR /home/pn/n8n
|
65 |
|
66 |
-
#
|
67 |
COPY --chown=pn:pn run.sh ./run.sh
|
68 |
RUN chmod +x ./run.sh \
|
69 |
&& mkdir -p /home/pn/.n8n \
|
|
|
10 |
ARG WEBHOOK_URL=https://你的hf账户名-空间名.hf.space/
|
11 |
ARG POSTGRESDB_PORT=5432
|
12 |
|
13 |
+
# 设置基本环境变量
|
14 |
+
ENV WEBHOOK_URL=${WEBHOOK_URL} \
|
15 |
+
N8N_HOST=0.0.0.0 \
|
16 |
+
N8N_PORT=7860 \
|
17 |
+
N8N_PROTOCOL=https \
|
18 |
+
GENERIC_TIMEZONE=Asia/Shanghai \
|
19 |
+
N8N_METRICS=true \
|
20 |
+
QUEUE_HEALTH_CHECK_ACTIVE=true \
|
21 |
+
N8N_PAYLOAD_SIZE_MAX=256 \
|
22 |
+
DB_TYPE=postgresdb \
|
23 |
+
DB_POSTGRESDB_PORT=${POSTGRESDB_PORT} \
|
24 |
+
VIRTUAL_ENV=/home/pn/venv \
|
25 |
+
PATH="/home/pn/venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH"
|
26 |
+
|
27 |
# 安装系统依赖
|
28 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
29 |
curl \
|
|
|
50 |
&& $VIRTUAL_ENV/bin/pip install --no-cache-dir --upgrade pip pnpm requests yt-dlp \
|
51 |
# 安装 n8n
|
52 |
&& npm install -g n8n@latest \
|
53 |
+
&& npm cache clean --force
|
|
|
|
|
|
|
|
|
54 |
|
55 |
+
# 创建环境变量文件
|
56 |
+
RUN --mount=type=secret,id=POSTGRES_USER,mode=0444,required=true \
|
57 |
+
--mount=type=secret,id=POSTGRES_PASSWORD,mode=0444,required=true \
|
58 |
+
--mount=type=secret,id=POSTGRES_DB,mode=0444,required=true \
|
59 |
+
--mount=type=secret,id=POSTGRESDB_HOST,mode=0444,required=true \
|
60 |
+
echo "DB_POSTGRESDB_HOST=$(cat /run/secrets/POSTGRESDB_HOST)" >> /tmp/env_vars && \
|
61 |
+
echo "DB_POSTGRESDB_USER=$(cat /run/secrets/POSTGRES_USER)" >> /tmp/env_vars && \
|
62 |
+
echo "DB_POSTGRESDB_PASSWORD=$(cat /run/secrets/POSTGRES_PASSWORD)" >> /tmp/env_vars && \
|
63 |
+
echo "DB_POSTGRESDB_DATABASE=$(cat /run/secrets/POSTGRES_DB)" >> /tmp/env_vars
|
64 |
+
|
65 |
+
# 导入数据库环境变量
|
66 |
+
SHELL ["/bin/bash", "-c"]
|
67 |
+
RUN source /tmp/env_vars && \
|
68 |
+
rm -f /tmp/env_vars
|
|
|
|
|
|
|
69 |
|
70 |
# 创建工作目录
|
71 |
WORKDIR /home/pn/n8n
|
72 |
|
73 |
+
# 复制启动脚本并创建数据目录
|
74 |
COPY --chown=pn:pn run.sh ./run.sh
|
75 |
RUN chmod +x ./run.sh \
|
76 |
&& mkdir -p /home/pn/.n8n \
|