Skip to content

Commit 8f9d586

Browse files
committed
fix: container now copies managed python into runtime
1 parent c8fc7b7 commit 8f9d586

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

.devcontainer/devcontainer.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
"remoteEnv": {
99
// Allow X11 apps to run inside the container
1010
"DISPLAY": "${localEnv:DISPLAY}",
11-
// We put venv on a different volume to cache so have to copy
12-
"UV_LINK_MODE": "copy",
1311
// Do the equivalent of "activate" the venv so we don't have to "uv run" everything
1412
"PATH": "/workspaces/${localWorkspaceFolderBasename}/.venv/bin:${containerEnv:PATH}"
1513
},

template/Dockerfile.jinja

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
# or docker with user namespaces.
33
FROM ghcr.io/diamondlightsource/ubuntu-devcontainer:noble AS developer
44

5+
# We will mount in a cache for uv, so silence warnings about it being on a different volume
6+
ENV UV_LINK_MODE=copy
7+
8+
# Cache the python download in the same directory as the uv cache
9+
ENV UV_PYTHON_CACHE_DIR=/root/.cache/uv/python
10+
511
# Add any system dependencies for the developer/build environment here
612
RUN apt-get update && apt-get install -y --no-install-recommends \
713
graphviz \
@@ -16,6 +22,9 @@ WORKDIR /app
1622
COPY . /app
1723
RUN chmod o+wrX .
1824

25+
# Tell uv sync to install python in a known location so we can copy it out later
26+
ENV UV_PYTHON_INSTALL_DIR=/python
27+
1928
# Sync the project without its dev dependencies
2029
RUN --mount=type=cache,target=/root/.cache/uv \
2130
uv sync --locked --no-editable --no-dev
@@ -50,6 +59,9 @@ FROM ubuntu:noble AS runtime
5059
# some-library \
5160
# && apt-get dist-clean
5261

62+
# Copy the python installation from the build stage
63+
COPY --from=build /python /python
64+
5365
# Copy the environment, but not the source code
5466
COPY --from=build /app/.venv /app/.venv
5567
ENV PATH=/app/.venv/bin:$PATH

0 commit comments

Comments
 (0)