-
Notifications
You must be signed in to change notification settings - Fork 394
Expand file tree
/
Copy pathDockerfile
More file actions
32 lines (21 loc) · 867 Bytes
/
Copy pathDockerfile
File metadata and controls
32 lines (21 loc) · 867 Bytes
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
# ── Stage 1: Builder ──────────────────────────────────────────
FROM python:3.11-slim AS builder
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir --prefix=/install -r requirements.txt
# ── Stage 2: Runtime ──────────────────────────────────────────
FROM python:3.11-slim
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
WORKDIR /app
# Copy only installed packages from builder stage
COPY --from=builder /install /usr/local
# Copy application code
COPY . .
# Create a non-root user and switch to it
RUN adduser --disabled-password --gecos "" appuser
USER appuser
EXPOSE 5000
CMD ["python", "src/app.py"]