Created
July 3, 2025 13:46
-
-
Save dannystaple/3958c0f66731e1093e669b7aaf06699f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Test this with | |
# export VERSION=17 && \ | |
# docker build --build-arg UV_VERSION="0.7.${VERSION}" . -f uv-test.Dockerfile -t uv-test:${VERSION} && \ | |
# docker run --rm -it --read-only --tmpfs /tmp:rw uv-test:${VERSION} | |
ARG UV_VERSION=0.7.17 | |
FROM ghcr.io/astral-sh/uv:$UV_VERSION AS uv | |
FROM python:3.13-slim | |
COPY --from=uv /uv /uvx /bin/ | |
WORKDIR /app | |
ARG USERNAME=app | |
ARG USER_UID=1000 | |
ARG USER_GID=$USER_UID | |
# Create the user | |
RUN groupadd --gid $USER_GID $USERNAME \ | |
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \ | |
&& chown $USERNAME:$USERNAME /app | |
# define the user to run the application | |
USER $USERNAME | |
# enable uv to run without cache | |
ENV UV_NO_CACHE=true | |
COPY pyproject.toml uv.lock /app/ | |
# install dependencies | |
RUN uv sync | |
ENV UV_FROZEN=true | |
ENV UV_NO_SYNC=true | |
CMD ["uv", "run", "python", "--version"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This gist is for python and astral/uv based containers. Used to test/validate astral-sh/uv#14404 and astral-sh/uv#14411.