Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
},
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -21,7 +21,7 @@ Releases | <https://github.com/DiamondLightSource/python-copier-template/
It integrates the following tools:

- [setuptools](https://setuptools.pypa.io) and [setuptools-scm](https://setuptools-scm.readthedocs.io) for packaging
- [pip](https://pip.pypa.io) to manage installation
- [uv](https://docs.astral.sh/uv/) to manage installation and project lockfile
- [pytest](https://docs.pytest.org) for code testing and coverage
- [pre-commit](https://pre-commit.com) to run linting and formatting such as [ruff](https://docs.astral.sh/ruff)
- [pyright](https://microsoft.github.io/pyright) or [mypy](https://www.mypy-lang.org) for static type checking
Expand Down
11 changes: 9 additions & 2 deletions template/Dockerfile.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}

Expand All @@ -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
Expand All @@ -36,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", "--" ]
Expand All @@ -46,10 +50,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
Expand Down