-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
33 lines (23 loc) · 796 Bytes
/
Copy pathDockerfile
File metadata and controls
33 lines (23 loc) · 796 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
33
# Stage 1: Builder
FROM python:3.11-slim AS builder
# Install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
WORKDIR /app
COPY . .
# Builder stage security patch
RUN pip install --no-cache-dir --upgrade pip setuptools wheel jaraco.context
RUN uv sync --frozen --no-dev
# Stage 2: Final
FROM python:3.11-slim
WORKDIR /app
# Final stage security patch
RUN pip install --no-cache-dir --upgrade pip setuptools wheel jaraco.context
# Copy artifacts from builder
COPY --from=builder /app/.venv /app/.venv
COPY --from=builder /app/math_ops.py /app/
# Environment path setup
ENV PATH="/app/.venv/bin:$PATH"
# Security: Create and use non-root user (using adduser for better compatibility)
RUN adduser --disabled-password --gecos '' appuser
USER appuser
CMD ["python", "math_ops.py"]