DecisionMaker / Dockerfile
paleDriver7's picture
Update Dockerfile
8be019c verified
raw
history blame
801 Bytes
# 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
WORKDIR /app
# 后端依赖
COPY backend/requirements.txt ./backend/requirements.txt
RUN pip install -r backend/requirements.txt
# 拷贝后端代码
COPY backend/ ./backend/
# 拷贝前端打包好的静态资源
COPY --from=frontend-build /app/frontend/dist ./frontend_dist
# 启动命令:运行后端,同时提供静态文件
CMD ["uvicorn", "backend.app:app", "--host", "0.0.0.0", "--port", "8000"]