Spaces:
Sleeping
Sleeping
File size: 1,047 Bytes
954551b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | # --- Build Stage: Frontend ---
FROM node:20-alpine AS frontend-builder
WORKDIR /app/frontend
COPY frontend/package*.json ./
RUN npm install
COPY frontend/ ./
# Set production environment for build
ENV NODE_ENV=production
RUN npm run build
# --- Stage: Final Image ---
FROM python:3.11-slim
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
gcc \
libpq-dev \
&& rm -rf /var/lib/apt/lists/*
# Copy backend requirements and install
COPY backend/requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
# Copy backend code
COPY backend/ ./
# Copy built frontend from previous stage to the static directory served by FastAPI
COPY --from=frontend-builder /app/frontend/out ./static
# Environment variables
ENV PORT=7860
ENV DATABASE_URL=""
# Hugging Face Spaces run on port 7860 by default
EXPOSE 7860
# Command to run the application
# We use uvicorn to run the FastAPI app, which now also serves the frontend
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
|