File size: 1,078 Bytes
178f666
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# ---- Stage 1: Build the Next.js Frontend ----
# Use a Node.js image to build our static frontend assets
FROM node:18-slim as frontend-builder

WORKDIR /app

# Copy only the frontend folder contents
COPY frontend/ ./

# Install dependencies and build the static site
RUN npm install
RUN npm run build


# ---- Stage 2: Build the final Python Application ----
# Use a Python image for the FastAPI backend
FROM python:3.10-slim

WORKDIR /app

# Copy Python requirements first for better caching
COPY backend/requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy the entire backend code
COPY backend/ .

# Copy the built frontend static files from the 'frontend-builder' stage
# The 'next build' command with 'output: export' places files in the 'out' directory
COPY --from=frontend-builder /app/out ./static

# Expose the port the app will run on
EXPOSE 7860

# Command to run the Uvicorn server
# Hugging Face Spaces expects the app to run on port 7860
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]