File size: 1,203 Bytes
75c7554
 
 
9f270f4
 
 
 
 
 
75c7554
 
9f270f4
75c7554
 
 
 
 
 
 
9f270f4
75c7554
9f270f4
75c7554
 
9f270f4
 
 
 
 
 
 
 
 
 
75c7554
ee949bc
75c7554
9f270f4
75c7554
 
9f270f4
75c7554
 
 
 
9f270f4
75c7554
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
42
43
44
45
46
47
48
# Stage 1: Build the React frontend
FROM node:20-alpine AS build-frontend
WORKDIR /frontend

# Optimize npm install (no audit, no fund, cache mount)
ENV NPM_CONFIG_PROGRESS=false \
    NPM_CONFIG_AUDIT=false \
    NPM_CONFIG_FUND=false

COPY frontend/package*.json ./
RUN npm install --frozen-lockfile || npm install

COPY frontend/ .
RUN npm run build

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

# Minimal system dependencies (remove gcc/g++ to save time/space)
RUN apt-get update && apt-get install -y --no-install-recommends \
    curl \
    && rm -rf /var/lib/apt/lists/*

# Optimize Python environment and PIP
ENV PYTHONPATH=/app \
    PORT=7860 \
    PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    PIP_NO_CACHE_DIR=1 \
    PIP_DISABLE_PIP_VERSION_CHECK=1 \
    PIP_DEFAULT_TIMEOUT=120

# Install Python dependencies
COPY backend/requirements.txt ./requirements.txt
RUN pip install -r requirements.txt

# Copy built frontend from Stage 1
COPY --from=build-frontend /frontend/dist ./frontend/dist

# Copy the entire project (respecting .dockerignore which now excludes node_modules)
COPY . .

EXPOSE 7860

# Run the unified FastAPI server
CMD ["python", "backend/main.py"]