Skip to content

Instantly share code, notes, and snippets.

@minimasoft
Last active December 5, 2025 23:27
Show Gist options
  • Select an option

  • Save minimasoft/7b68c25165a2ffef46565821937ccdd1 to your computer and use it in GitHub Desktop.

Select an option

Save minimasoft/7b68c25165a2ffef46565821937ccdd1 to your computer and use it in GitHub Desktop.
Proper python app dockerfile.
FROM ghcr.io/astral-sh/uv:alpine@sha256:abba5681efde355627953bb7a07b5091292628a071ebfe3ca3929fe3edb248b1 AS builder
RUN adduser -D pyuser
RUN mkdir /home/pyuser/app && chown -R pyuser:pyuser /home/pyuser/*
USER pyuser
WORKDIR /home/pyuser/app
COPY pyproject.toml uv.lock ./
RUN uv sync -n
FROM alpine:3.22@sha256:8a1f59ffb675680d47db6337b49d22281a139e9d709335b492be023728e11715 AS runtime
RUN adduser -D pyuser
USER pyuser
# python is fetched here
COPY --from=builder /home/pyuser/.local /home/pyuser/.local
WORKDIR /home/pyuser/app
COPY --from=builder /home/pyuser/app ./
COPY app ./app
COPY tasks ./tasks
COPY scripts ./scripts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment