Spaces:
Build error
Build error
| # Stage 1: Build React frontend | |
| FROM node:20-alpine AS frontend-build | |
| WORKDIR /app/frontend | |
| COPY frontend/package*.json ./ | |
| RUN npm install | |
| COPY frontend/ ./ | |
| RUN npm run build | |
| # Stage 2: Set up Python backend | |
| FROM python:3.12-slim | |
| # System deps | |
| RUN apt-get update && apt-get install -y build-essential && rm -rf /var/lib/apt/lists/* | |
| WORKDIR /app/backend | |
| COPY backend/requirements.txt ./ | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy backend code | |
| COPY backend/ ./ | |
| # Copy React build to backend static folder | |
| COPY --from=frontend-build /app/frontend/build ./frontend/build | |
| # Env vars (you can set them in Docker Space UI too) | |
| ENV FLASK_APP=app.py | |
| ENV FLASK_ENV=production | |
| ENV PORT=7860 | |
| EXPOSE 7860 | |
| # Start Flask | |
| CMD ["python", "app.py"] |