Commit 67e43a7f authored by dev-user-56145a-1749186738's avatar dev-user-56145a-1749186738
parents e60e2709 dd4f5471
# 多阶段构建:Python + Node.js 全栈应用
FROM hb.eazytec-cloud.com/eazytec/eazydevelop-python-node:ubuntu22.04-python3.11-node22 AS python-base
FROM hb.eazytec-cloud.com/eazytec/eazydevelop-python-node:ubuntu22.04-python3.12-node22 AS python-base
# 设置工作目录
WORKDIR /app
......@@ -16,7 +16,7 @@ RUN pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple/ &&
pip install --no-cache-dir -r backend/requirements.txt
# Node.js 阶段
FROM hb.eazytec-cloud.com/eazytec/eazydevelop-python-node:ubuntu22.04-python3.11-node22 AS node-base
FROM hb.eazytec-cloud.com/eazytec/eazydevelop-python-node:ubuntu22.04-python3.12-node22 AS node-base
# 设置工作目录
WORKDIR /app
......@@ -33,14 +33,14 @@ RUN cd frontend && npm config set registry https://registry.npmmirror.com && \
npm install --production
# 最终阶段:合并两个服务
FROM hb.eazytec-cloud.com/eazytec/eazydevelop-python-node:ubuntu22.04-python3.11-node22
FROM hb.eazytec-cloud.com/eazytec/eazydevelop-python-node:ubuntu22.04-python3.12-node22
# 设置工作目录
WORKDIR /app
# 复制 Python 后端
COPY --from=python-base /app/backend/ /app/backend/
COPY --from=python-base /usr/local/lib/python3.11/site-packages/ /usr/local/lib/python3.11/site-packages/
COPY --from=python-base /usr/local/lib/python3.12/site-packages/ /usr/local/lib/python3.12/site-packages/
# 复制 Node.js 前端
COPY --from=node-base /app/frontend/ /app/frontend/
......@@ -51,19 +51,16 @@ COPY --from=node-base /usr/local/lib/node_modules/ /usr/local/lib/node_modules/
# 复制资源文件
COPY .resource/ /app/.resource/
# 拷贝启动脚本
COPY start.sh /app/start.sh
# 设置环境变量
ENV RESOURCE_PATH=/app/.resource/resource_deploy.json
ENV PYTHONPATH=/app/backend
ENV NODE_ENV=production
# 创建启动脚本
RUN echo '#!/bin/bash\n\
# 启动 Python 后端\n\
cd /app/backend && python app.py &\n\
# 启动 Node.js 前端\n\
cd /app/frontend && node server.js &\n\
# 等待所有后台进程\n\
wait' > /app/start.sh && chmod +x /app/start.sh
# 设置启动脚本权限
RUN chmod +x /app/start.sh
# 暴露端口
EXPOSE $APP_PORT_1 $APP_PORT_2
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment