Sadum1's picture
Upload folder using huggingface_hub
930e4a4 verified
Raw History Blame Contribute Delete
1.04 kB
# Multi-stage build: compile the frontend, then serve it + the API from one
# Python image. Hugging Face Docker Spaces require the app to listen on
# port 7860 (see app_port in README.md's Space config below).
# --- Stage 1: build the React frontend -------------------------------------
FROM node:20-slim AS frontend-build
WORKDIR /app/frontend
COPY frontend/package.json frontend/package-lock.json* ./
RUN npm install
COPY frontend/ ./
RUN npm run build
# --- Stage 2: Python backend, serving the built frontend as static files ---
FROM python:3.11-slim
WORKDIR /app/backend
COPY backend/requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
COPY backend/ ./
# main.py looks for ../../frontend/dist relative to app/main.py, i.e.
# /app/frontend/dist from this WORKDIR � matches the path below.
COPY --from=frontend-build /app/frontend/dist /app/frontend/dist
# Hugging Face Docker Spaces expect port 7860.
ENV PORT=7860
EXPOSE 7860
CMD ["sh", "-c", "uvicorn app.main:app --host 0.0.0.0 --port ${PORT:-7860}"]