Spaces:
Paused
Paused
# 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"] | |