Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
51 lines (35 loc) · 1.65 KB
/
Copy pathDockerfile
File metadata and controls
51 lines (35 loc) · 1.65 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
49
50
51
# https://github.com/astral-sh/uv-docker-example/blob/c16a61fb3e6ab568ac58d94b73a7d79594a5d570/Dockerfile
# A named stage, not COPY --from=<image>: Dependabot only updates FROM lines.
FROM ghcr.io/astral-sh/uv:0.13.9@sha256:d3b601f0c7b118bc1753febf7c41cc80981df678445e0254284eecf84db79a7d AS uv
# Build stage
FROM python:3.13-slim AS builder
WORKDIR /app
ENV UV_COMPILE_BYTECODE=1
ENV UV_LINK_MODE=copy
ENV UV_PROJECT_ENVIRONMENT=/usr/local
COPY --from=uv /uv /uvx /bin/
# Install the project's dependencies using the lockfile and settings
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --frozen --no-install-project --no-dev --extra metrics
# Then, add the rest of the project source code and install it
# Installing separately from its dependencies allows optimal layer caching
ADD . /app
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-dev --extra metrics
# Runtime stage
FROM python:3.13-slim
WORKDIR /app
# Copy installed packages from builder
COPY --from=builder /usr/local/lib/python3.13/site-packages /usr/local/lib/python3.13/site-packages
COPY --from=builder /usr/local/bin /usr/local/bin
# Copy only the source code directory needed at runtime
COPY --from=builder /app/src/stac_auth_proxy /app/src/stac_auth_proxy
# Nothing at runtime uses pip. Images built on this one can run python -m ensurepip, then python -m pip.
RUN python -m pip uninstall -y pip && \
useradd -m -u 1001 -s /bin/bash user && \
chown -R user:user /app
USER user
ENV PYTHONPATH=/app/src
CMD ["python", "-m", "stac_auth_proxy"]