1- # The devcontainer should use the developer target and run as root with podman
2- # or docker with user namespaces.
1+ # Use this version of Python
32ARG PYTHON_VERSION=3.11
4- FROM python:${PYTHON_VERSION} AS developer
5-
63# Use this version of uv
74ARG UV_VERSION=0.7
85
6+ # Install uv using the official image
7+ # See https://docs.astral.sh/uv/guides/integration/docker/#installing-uv
8+ FROM ghcr.io/astral-sh/uv:${UV_VERSION} AS uv-distroless
9+
10+ # The devcontainer should use the developer target and run as root with podman
11+ # or docker with user namespaces.
12+ FROM python:${PYTHON_VERSION} AS developer
13+
914# Add any system dependencies for the developer/build environment here
1015# RUN apt-get update && apt-get install -y --no-install-recommends \
1116# graphviz
1217
13- # Install uv using the official image
14- # See https://docs.astral.sh/uv/guides/integration/docker/#installing-uv
15- COPY --from=ghcr.io/astral-sh/uv:${UV_VERSION} /uv /uvx /bin/{% if docker %}
18+ # Install from uv image
19+ COPY --from=uv-distroless /uv /uvx /bin/{% if docker %}
1620
1721# The build stage installs the context into the venv
1822FROM developer AS build
19- COPY . /context
23+ # Copy only dependency files first
24+ COPY pyproject.toml uv.lock /context/
2025WORKDIR /context
2126
2227# Enable bytecode compilation and copy from the cache instead of linking
@@ -41,8 +46,8 @@ FROM python:${PYTHON_VERSION}-slim AS runtime
4146# Add apt-get system dependecies for runtime here if needed
4247
4348# We need to keep the venv at the same absolute path as in the build stage
44- COPY --from=build /context/venv/ /context/venv/
45- ENV PATH=/context/venv/bin:$PATH
49+ COPY --from=build /context/. venv/ /context/. venv/
50+ ENV PATH=/context/. venv/bin:$PATH
4651
4752# Change this entrypoint if it is not the same as the repo
4853ENTRYPOINT ["{{ repo_name }}"]
0 commit comments