Spaces:
Sleeping
Sleeping
| # Stage 1: Build the Next.js frontend | |
| FROM node:20-alpine AS frontend_builder | |
| WORKDIR /app/frontend | |
| COPY frontend/package*.json ./ | |
| RUN npm ci | |
| COPY frontend/ ./ | |
| RUN npm run build | |
| # Stage 2: Build the FastAPI backend | |
| FROM python:3.10-slim | |
| WORKDIR /app | |
| # Create a non-root user (Hugging Face standard) | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH | |
| WORKDIR $HOME/app | |
| # Copy requirements and install | |
| COPY --chown=user requirements.txt . | |
| RUN pip install --no-cache-dir --upgrade -r requirements.txt | |
| # Copy backend files | |
| COPY --chown=user . . | |
| # Copy the built frontend static files from Stage 1 into the Python container | |
| COPY --chown=user --from=frontend_builder /app/frontend/out ./frontend/out | |
| # Hugging Face Spaces standard port | |
| EXPOSE 7860 | |
| # Command to run the application (FastAPI on 0.0.0.0:7860) | |
| CMD ["uvicorn", "api:app", "--host", "0.0.0.0", "--port", "7860"] | |