- Dockerfile +8 -14
Dockerfile
CHANGED
@@ -12,15 +12,17 @@ ARG DUMP_PASSWORD
|
|
12 |
# 安装 Node.js、n8n 以及必要的系统工具
|
13 |
RUN apt-get update && apt-get install -y curl gnupg build-essential && \
|
14 |
curl -fsSL https://deb.nodesource.com/setup_${NODEJS_VER}.x | bash - && \
|
15 |
-
apt-get install -y nodejs && \
|
16 |
-
npm install -g ${PACKAGES} && \
|
17 |
apt-get clean && rm -rf /var/lib/apt/lists/*
|
18 |
|
|
|
|
|
|
|
19 |
# 设置 Python 虚拟环境
|
20 |
ENV VIRTUAL_ENV=/opt/venv
|
21 |
RUN python3 -m venv $VIRTUAL_ENV && \
|
22 |
$VIRTUAL_ENV/bin/pip install --upgrade pip && \
|
23 |
-
$VIRTUAL_ENV/bin/pip install $
|
24 |
|
25 |
# 主运行阶段:基于较小的 PostgreSQL 镜像
|
26 |
FROM postgres:latest
|
@@ -31,7 +33,7 @@ ARG POSTGRES_PASSWORD=n8n
|
|
31 |
ARG POSTGRES_DB=n8n
|
32 |
ARG WEBHOOK_URL=https://aigenai-db.hf.space/
|
33 |
ARG WORKDIR=/app
|
34 |
-
ARG DB_IMPORT=no
|
35 |
|
36 |
# 设置 n8n 环境变量
|
37 |
ENV N8N_HOST=0.0.0.0 \
|
@@ -57,7 +59,8 @@ ENV VIRTUAL_ENV=/opt/venv \
|
|
57 |
|
58 |
# 复制构建阶段的 n8n 和 Python 运行环境
|
59 |
COPY --from=builder /usr/local/bin/node /usr/local/bin/node
|
60 |
-
COPY --from=builder /usr/
|
|
|
61 |
COPY --from=builder $VIRTUAL_ENV $VIRTUAL_ENV
|
62 |
|
63 |
# 安装必要的软件包
|
@@ -91,15 +94,6 @@ RUN initdb -D /var/lib/postgresql/data && \
|
|
91 |
COPY import-db.sh /docker-entrypoint-initdb.d/
|
92 |
RUN chmod +x /docker-entrypoint-initdb.d/import-db.sh
|
93 |
|
94 |
-
# 脚本 import-db.sh 的内容:
|
95 |
-
# #!/bin/bash
|
96 |
-
# if [ "$DB_IMPORT" = "yes" ]; then
|
97 |
-
# echo "Importing database dump..."
|
98 |
-
# psql -U $POSTGRES_USER -d $POSTGRES_DB -f /docker-entrypoint-initdb.d/dump.sql
|
99 |
-
# else
|
100 |
-
# echo "Skipping database import."
|
101 |
-
# fi
|
102 |
-
|
103 |
# 健康检查配置(可选)
|
104 |
HEALTHCHECK --interval=120s --timeout=10s --start-period=10s --retries=3 \
|
105 |
CMD curl -f http://localhost:7860/HEALTHZ || exit 1
|
|
|
12 |
# 安装 Node.js、n8n 以及必要的系统工具
|
13 |
RUN apt-get update && apt-get install -y curl gnupg build-essential && \
|
14 |
curl -fsSL https://deb.nodesource.com/setup_${NODEJS_VER}.x | bash - && \
|
15 |
+
apt-get install -y nodejs && npm install -g ${PACKAGES} && \
|
|
|
16 |
apt-get clean && rm -rf /var/lib/apt/lists/*
|
17 |
|
18 |
+
# 验证 Node.js 和 npm 安装的 node_modules 路径是否存在
|
19 |
+
RUN ls -al /usr/local/lib/node_modules || echo "node_modules not found!"
|
20 |
+
|
21 |
# 设置 Python 虚拟环境
|
22 |
ENV VIRTUAL_ENV=/opt/venv
|
23 |
RUN python3 -m venv $VIRTUAL_ENV && \
|
24 |
$VIRTUAL_ENV/bin/pip install --upgrade pip && \
|
25 |
+
$VIRTUAL_ENV/bin/pip install $requirements
|
26 |
|
27 |
# 主运行阶段:基于较小的 PostgreSQL 镜像
|
28 |
FROM postgres:latest
|
|
|
33 |
ARG POSTGRES_DB=n8n
|
34 |
ARG WEBHOOK_URL=https://aigenai-db.hf.space/
|
35 |
ARG WORKDIR=/app
|
36 |
+
ARG DB_IMPORT=no
|
37 |
|
38 |
# 设置 n8n 环境变量
|
39 |
ENV N8N_HOST=0.0.0.0 \
|
|
|
59 |
|
60 |
# 复制构建阶段的 n8n 和 Python 运行环境
|
61 |
COPY --from=builder /usr/local/bin/node /usr/local/bin/node
|
62 |
+
COPY --from=builder /usr/lib/node_modules /usr/lib/node_modules || echo "Skipping node_modules copy, not found."
|
63 |
+
COPY --from=builder /usr/local/lib/node_modules /usr/local/lib/node_modules || echo "Skipping node_modules copy, not found."
|
64 |
COPY --from=builder $VIRTUAL_ENV $VIRTUAL_ENV
|
65 |
|
66 |
# 安装必要的软件包
|
|
|
94 |
COPY import-db.sh /docker-entrypoint-initdb.d/
|
95 |
RUN chmod +x /docker-entrypoint-initdb.d/import-db.sh
|
96 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
# 健康检查配置(可选)
|
98 |
HEALTHCHECK --interval=120s --timeout=10s --start-period=10s --retries=3 \
|
99 |
CMD curl -f http://localhost:7860/HEALTHZ || exit 1
|