-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
48 lines (32 loc) · 1.1 KB
/
Copy pathDockerfile
File metadata and controls
48 lines (32 loc) · 1.1 KB
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
FROM ghcr.io/astral-sh/uv:python3.14-bookworm-slim AS builder
WORKDIR /app
# Enable bytecode compilation for faster startup
ENV UV_COMPILE_BYTECODE=1
# Copy from the cache instead of linking since it's a mounted cache
ENV UV_LINK_MODE=copy
# Copy dependency files first for better layer caching
COPY pyproject.toml uv.lock ./
# Install dependencies (without dev dependencies)
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-install-project --no-dev
# Copy application code
COPY main.py ./
# Sync the project
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-dev
FROM python:3.14-slim-bookworm
WORKDIR /app
# Version info from build args
ARG APP_VERSION=dev
ENV APP_VERSION=${APP_VERSION}
# Create non-root user for security
RUN useradd --create-home --shell /bin/bash app
# Copy the virtual environment from builder
COPY --from=builder --chown=app:app /app/.venv /app/.venv
# Copy application code
COPY --chown=app:app main.py ./
# Use the virtual environment
ENV PATH="/app/.venv/bin:$PATH"
# Switch to non-root user
USER app
ENTRYPOINT ["python", "main.py"]