Spaces:
Paused
Paused
File size: 809 Bytes
ed45b2b 6134208 e2668b4 ed45b2b e2668b4 cb921c1 c50b7a7 ed45b2b e2668b4 d185393 c50b7a7 e2668b4 90e0ad0 ed45b2b e2668b4 cb921c1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
# you will also find guides on how best to write your Dockerfile
# 使用多阶段构建
# 阶段 1:构建前端
FROM node:16 AS frontend-build
WORKDIR /app/frontend
COPY frontend/package*.json ./
RUN npm install
COPY frontend/ .
RUN npm run build
# 阶段 2:运行后端 + 提供前端静态资源
FROM python:3.9-slim
WORKDIR /app/backend
# 后端依赖
COPY backend/requirements.txt ./backend/requirements.txt
RUN pip install -r backend/requirements.txt
# 拷贝后端代码
COPY backend/ ./backend/
# 拷贝前端打包好的静态资源
COPY --from=frontend-build /app/frontend/dist /app/backend/frontend_dist
# 启动命令:运行后端,同时提供静态文件
CMD ["gunicorn", "-b", "0.0.0.0:7860", "backend.app:app"]
|