File size: 955 Bytes
aff341e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# -------- Stage 1: Build frontend (Vite + React) --------
FROM node:20-alpine AS frontend-builder
WORKDIR /frontend

# Install deps first (better layer caching)
COPY frontend/package*.json ./
COPY frontend/tsconfig.json frontend/vite.config.* frontend/index.html ./
RUN npm install

# Copy source and build
COPY frontend/src ./src
RUN npm run build

# -------- Stage 2: Backend runtime (FastAPI + Uvicorn) --------
FROM python:3.12-slim AS runtime
ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1

WORKDIR /app

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

# Copy backend code
COPY backend ./backend

# Copy built frontend into expected path (/app/frontend/dist)
COPY --from=frontend-builder /frontend/dist ./frontend/dist

EXPOSE 7860

# Default command
CMD ["python", "-m", "uvicorn", "backend.app:app", "--host", "0.0.0.0", "--port", "7860"]