File size: 1,076 Bytes
34d0dc9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# --- Stage 1: Build the Frontend ---
FROM node:20-alpine AS frontend-builder
WORKDIR /app/Frontend
COPY Frontend/package*.json ./
RUN npm install
COPY Frontend/ ./
RUN npm run build

# --- Stage 2: Final Backend Image ---
FROM python:3.11-slim
WORKDIR /app

# Install system dependencies (needed for certain python packages)
RUN apt-get update && apt-get install -y \

    build-essential \
    libpq-dev \
    && rm -rf /var/lib/apt/lists/*

# Install Backend dependencies
COPY Backend/requirements.txt ./Backend/
RUN pip install --no-cache-dir -r Backend/requirements.txt

# Copy Backend source code
COPY Backend/ ./Backend/

# Copy the built Frontend files to the Backend's dist directory
# (FastAPI in Backend/main.py is configured to serve this)
COPY --from=frontend-builder /app/Frontend/dist ./Backend/dist

# Expose the API port (Hugging Face Spaces defaults to 8000/7860)
EXPOSE 7860

# Set the working directory to Backend for file imports to work
WORKDIR /app/Backend

# Command to run the application
CMD ["python", "main.py"]