Update Dockerfile
Browse files- Dockerfile +10 -9
Dockerfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
#
|
2 |
FROM node:20-slim AS builder
|
3 |
|
4 |
# 设置构建时变量
|
@@ -8,11 +8,14 @@ ARG WORKDIR=/app
|
|
8 |
ARG DUMP_URL
|
9 |
ARG DUMP_PASSWORD
|
10 |
|
11 |
-
# 安装
|
12 |
RUN apt-get update && apt-get install -y python3 python3-venv curl gnupg build-essential && \
|
13 |
npm install -g ${PACKAGES} && \
|
14 |
apt-get clean && rm -rf /var/lib/apt/lists/*
|
15 |
|
|
|
|
|
|
|
16 |
# 设置 Python 虚拟环境
|
17 |
ENV VIRTUAL_ENV=/opt/venv
|
18 |
RUN python3 -m venv $VIRTUAL_ENV && \
|
@@ -48,11 +51,12 @@ ENV DB_TYPE=postgresdb \
|
|
48 |
DB_POSTGRESDB_PASSWORD=${POSTGRES_PASSWORD} \
|
49 |
DB_POSTGRESDB_DATABASE=${POSTGRES_DB}
|
50 |
|
51 |
-
# 设置 Python
|
52 |
ENV VIRTUAL_ENV=/opt/venv \
|
53 |
-
PATH="$VIRTUAL_ENV/bin
|
54 |
|
55 |
# 复制构建阶段的 n8n 和 Python 运行环境
|
|
|
56 |
COPY --from=builder /usr/local/lib/node_modules /usr/local/lib/node_modules
|
57 |
COPY --from=builder $VIRTUAL_ENV $VIRTUAL_ENV
|
58 |
|
@@ -69,10 +73,6 @@ WORKDIR ${WORKDIR}
|
|
69 |
COPY run.sh ${WORKDIR}/run.sh
|
70 |
RUN chmod +x ${WORKDIR}/run.sh
|
71 |
|
72 |
-
# 以 root 用户复制 import-db.sh 并设置权限
|
73 |
-
COPY import-db.sh /docker-entrypoint-initdb.d/
|
74 |
-
RUN chmod +x /docker-entrypoint-initdb.d/import-db.sh
|
75 |
-
|
76 |
# 更改现有的 postgres 用户 UID 和 GID 为 1000
|
77 |
USER root
|
78 |
RUN usermod -u 1000 postgres && groupmod -g 1000 postgres && \
|
@@ -87,6 +87,7 @@ RUN initdb -D /var/lib/postgresql/data && \
|
|
87 |
createdb -O $POSTGRES_USER $POSTGRES_DB && \
|
88 |
pg_ctl stop -D /var/lib/postgresql/data
|
89 |
|
|
|
90 |
# 添加条件导入的 shell 脚本
|
91 |
COPY import-db.sh /docker-entrypoint-initdb.d/
|
92 |
RUN chmod +x /docker-entrypoint-initdb.d/import-db.sh
|
@@ -96,4 +97,4 @@ HEALTHCHECK --interval=120s --timeout=10s --start-period=10s --retries=3 \
|
|
96 |
CMD curl -f http://localhost:7860/HEALTHZ || exit 1
|
97 |
|
98 |
# 启动容器时执行run.sh脚本
|
99 |
-
CMD ["./run.sh"]
|
|
|
1 |
+
# 基础构建阶段:使用 Node.js 镜像并安装 Python3 和虚拟环境
|
2 |
FROM node:20-slim AS builder
|
3 |
|
4 |
# 设置构建时变量
|
|
|
8 |
ARG DUMP_URL
|
9 |
ARG DUMP_PASSWORD
|
10 |
|
11 |
+
# 安装 Python3、venv 以及必要的系统工具
|
12 |
RUN apt-get update && apt-get install -y python3 python3-venv curl gnupg build-essential && \
|
13 |
npm install -g ${PACKAGES} && \
|
14 |
apt-get clean && rm -rf /var/lib/apt/lists/*
|
15 |
|
16 |
+
# 验证 Node.js 和 npm 安装的 node_modules 路径是否存在
|
17 |
+
RUN ls -al /usr/local/lib/node_modules || echo "node_modules not found!"
|
18 |
+
|
19 |
# 设置 Python 虚拟环境
|
20 |
ENV VIRTUAL_ENV=/opt/venv
|
21 |
RUN python3 -m venv $VIRTUAL_ENV && \
|
|
|
51 |
DB_POSTGRESDB_PASSWORD=${POSTGRES_PASSWORD} \
|
52 |
DB_POSTGRESDB_DATABASE=${POSTGRES_DB}
|
53 |
|
54 |
+
# 设置 Python 环境变量
|
55 |
ENV VIRTUAL_ENV=/opt/venv \
|
56 |
+
PATH="$VIRTUAL_ENV/bin:$PATH"
|
57 |
|
58 |
# 复制构建阶段的 n8n 和 Python 运行环境
|
59 |
+
COPY --from=builder /usr/local/bin/node /usr/local/bin/node
|
60 |
COPY --from=builder /usr/local/lib/node_modules /usr/local/lib/node_modules
|
61 |
COPY --from=builder $VIRTUAL_ENV $VIRTUAL_ENV
|
62 |
|
|
|
73 |
COPY run.sh ${WORKDIR}/run.sh
|
74 |
RUN chmod +x ${WORKDIR}/run.sh
|
75 |
|
|
|
|
|
|
|
|
|
76 |
# 更改现有的 postgres 用户 UID 和 GID 为 1000
|
77 |
USER root
|
78 |
RUN usermod -u 1000 postgres && groupmod -g 1000 postgres && \
|
|
|
87 |
createdb -O $POSTGRES_USER $POSTGRES_DB && \
|
88 |
pg_ctl stop -D /var/lib/postgresql/data
|
89 |
|
90 |
+
USER root
|
91 |
# 添加条件导入的 shell 脚本
|
92 |
COPY import-db.sh /docker-entrypoint-initdb.d/
|
93 |
RUN chmod +x /docker-entrypoint-initdb.d/import-db.sh
|
|
|
97 |
CMD curl -f http://localhost:7860/HEALTHZ || exit 1
|
98 |
|
99 |
# 启动容器时执行run.sh脚本
|
100 |
+
CMD ["./run.sh"]
|