File size: 1,154 Bytes
5462a86
 
 
 
e2b6da8
5462a86
e2b6da8
 
5462a86
e2b6da8
 
 
5462a86
 
 
 
e2b6da8
 
 
1f63da8
e2b6da8
 
 
5462a86
79ee284
5462a86
e2b6da8
 
 
 
 
 
79ee284
e2b6da8
 
79ee284
 
5462a86
79ee284
e2b6da8
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
# ==========================================
# Stage 1: Build the React + Vite 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: Setup the Python FastAPI Backend
# ==========================================
FROM python:3.10-slim
WORKDIR /app

COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt


# ==========================================
# Stage 3: Hugging Face User Permissions & Final Assembly
# ==========================================
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH
WORKDIR $HOME/app

# 1. Copy the backend and local project files into the user directory
COPY --chown=user . $HOME/app

# 2. Copy the compiled React frontend from Stage 1 into the EXACT folder FastAPI expects
COPY --chown=user --from=frontend-builder /app/frontend/dist $HOME/app/frontend/dist

EXPOSE 7860
CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "7860"]