Skip to content

Commit 0cb66d4

Browse files
committed
Fix Dockerfiles (move UV_VERSION to top of file, and assign new build step)
1 parent d05f036 commit 0cb66d4

File tree

2 files changed

+28
-15
lines changed

2 files changed

+28
-15
lines changed

Dockerfile

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
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
32
ARG PYTHON_VERSION=3.11
4-
FROM python:${PYTHON_VERSION} AS developer
5-
63
# Use this version of uv
74
ARG UV_VERSION=0.7
85

96
# Install uv using the official image
107
# See https://docs.astral.sh/uv/guides/integration/docker/#installing-uv
11-
COPY --from=ghcr.io/astral-sh/uv:${UV_VERSION} /uv /uvx /bin/
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+
14+
# Add any system dependencies for the developer/build environment here
15+
# RUN apt-get update && apt-get install -y --no-install-recommends \
16+
# graphviz
17+
18+
# Install from uv image
19+
COPY --from=uv-distroless /uv /uvx /bin/

template/Dockerfile.jinja

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
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
32
ARG PYTHON_VERSION=3.11
4-
FROM python:${PYTHON_VERSION} AS developer
5-
63
# Use this version of uv
74
ARG 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
1822
FROM developer AS build
19-
COPY . /context
23+
# Copy only dependency files first
24+
COPY pyproject.toml uv.lock /context/
2025
WORKDIR /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
4853
ENTRYPOINT ["{{ repo_name }}"]

0 commit comments

Comments
 (0)