File tree Expand file tree Collapse file tree 1 file changed +22
-3
lines changed
Expand file tree Collapse file tree 1 file changed +22
-3
lines changed Original file line number Diff line number Diff line change 1- FROM python:3.11-slim
1+ # Build stage - compile dependencies
2+ FROM python:3.11-slim AS builder
23
34WORKDIR /app
45
5- # Install system dependencies
6+ # Install build dependencies (only in this stage)
67RUN apt-get update && apt-get install -y --no-install-recommends \
78 gcc \
9+ libssl-dev \
10+ libffi-dev \
11+ python3-dev \
12+ cargo \
13+ rustc \
814 && rm -rf /var/lib/apt/lists/*
915
1016# Install Python dependencies
1117COPY requirements.txt .
1218RUN pip install --no-cache-dir --upgrade pip && \
13- pip install --no-cache-dir -r requirements.txt
19+ pip install --no-cache-dir --prefix=/install -r requirements.txt
20+
21+ # Final stage - minimal runtime image
22+ FROM python:3.11-slim
23+
24+ WORKDIR /app
25+
26+ # Install only runtime dependencies (not build tools!)
27+ RUN apt-get update && apt-get install -y --no-install-recommends \
28+ libssl3 \
29+ && rm -rf /var/lib/apt/lists/*
30+
31+ # Copy installed Python packages from builder
32+ COPY --from=builder /install /usr/local
1433
1534# Copy application files
1635COPY backend ./backend
You can’t perform that action at this time.
0 commit comments