From 470d4fc74db6a84e6c5fc6a1cc47ea7b946c4415 Mon Sep 17 00:00:00 2001 From: Tom Cobb Date: Wed, 1 Oct 2025 15:33:14 +0000 Subject: [PATCH 1/3] fix: container now copies managed python into runtime --- .devcontainer/devcontainer.json | 2 -- Dockerfile | 2 +- template/Dockerfile.jinja | 10 ++++++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 84ba5d6c..8f7d1102 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -8,8 +8,6 @@ "remoteEnv": { // Allow X11 apps to run inside the container "DISPLAY": "${localEnv:DISPLAY}", - // We put venv on a different volume to cache so have to copy - "UV_LINK_MODE": "copy", // Do the equivalent of "activate" the venv so we don't have to "uv run" everything "PATH": "/workspaces/${localWorkspaceFolderBasename}/.venv/bin:${containerEnv:PATH}" }, diff --git a/Dockerfile b/Dockerfile index dd7f8c3a..d4dfcaaf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,6 @@ FROM ghcr.io/diamondlightsource/ubuntu-devcontainer:noble AS developer # Add any system dependencies for the developer/build environment here -RUN apt-get update && apt-get install -y --no-install-recommends \ +RUN apt-get update -y && apt-get install -y --no-install-recommends \ graphviz \ && apt-get dist-clean diff --git a/template/Dockerfile.jinja b/template/Dockerfile.jinja index dd522313..daac962c 100644 --- a/template/Dockerfile.jinja +++ b/template/Dockerfile.jinja @@ -3,7 +3,7 @@ FROM ghcr.io/diamondlightsource/ubuntu-devcontainer:noble AS developer # Add any system dependencies for the developer/build environment here -RUN apt-get update && apt-get install -y --no-install-recommends \ +RUN apt-get update -y && apt-get install -y --no-install-recommends \ graphviz \ && apt-get dist-clean{% if docker %} @@ -16,6 +16,9 @@ WORKDIR /app COPY . /app RUN chmod o+wrX . +# Tell uv sync to install python in a known location so we can copy it out later +ENV UV_PYTHON_INSTALL_DIR=/python + # Sync the project without its dev dependencies RUN --mount=type=cache,target=/root/.cache/uv \ uv sync --locked --no-editable --no-dev @@ -46,10 +49,13 @@ CMD [ "while true; do sleep 30; done;" ] FROM ubuntu:noble AS runtime # Add apt-get system dependecies for runtime here if needed -# RUN apt-get update && apt-get install -y --no-install-recommends \ +# RUN apt-get update -y && apt-get install -y --no-install-recommends \ # some-library \ # && apt-get dist-clean +# Copy the python installation from the build stage +COPY --from=build /python /python + # Copy the environment, but not the source code COPY --from=build /app/.venv /app/.venv ENV PATH=/app/.venv/bin:$PATH From 108334ba06a1a0b2e48c89924389c3d9a8e62b04 Mon Sep 17 00:00:00 2001 From: Tom Cobb Date: Thu, 2 Oct 2025 15:32:57 +0000 Subject: [PATCH 2/3] Add debug path too --- template/Dockerfile.jinja | 1 + 1 file changed, 1 insertion(+) diff --git a/template/Dockerfile.jinja b/template/Dockerfile.jinja index daac962c..87d417ac 100644 --- a/template/Dockerfile.jinja +++ b/template/Dockerfile.jinja @@ -39,6 +39,7 @@ RUN sed -i 's/files/ldap files/g' /etc/nsswitch.conf # Make editable and debuggable RUN uv pip install debugpy RUN uv pip install -e . +ENV PATH=/app/.venv/bin:$PATH # Alternate entrypoint to allow devcontainer to attach ENTRYPOINT [ "/bin/bash", "-c", "--" ] From 779ec8e7ffc5ca40e8480618ab0454ffdf06fff7 Mon Sep 17 00:00:00 2001 From: Tom Cobb Date: Thu, 2 Oct 2025 15:38:17 +0000 Subject: [PATCH 3/3] Update README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 96f72ded..0bf5a5ca 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ # python-copier-template -Diamond's opinionated [copier](https://copier.readthedocs.io) template for pure Python projects managed by pip. It can be optionally used to: +Diamond's opinionated [copier](https://copier.readthedocs.io) template for pure Python projects. It can be optionally used to: - Create new projects from - Update existing projects in line with it @@ -21,7 +21,7 @@ Releases |