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
12 changes: 8 additions & 4 deletions template/{% if enable_container %}Dockerfile{% endif %}.jinja
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
{%- import "includes/python.jinja" as py with context -%}
FROM ghcr.io/astral-sh/uv:python{{ py.latest() }}-bookworm-slim
FROM ghcr.io/astral-sh/uv:python{{ py.latest() }}-bookworm-slim AS builder

WORKDIR /app

# Install dependencies first (cached layer, only invalidated by pyproject.toml changes)
COPY pyproject.toml ./
COPY pyproject.toml README.md .
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --no-dev --no-install-project

# Copy source and install project
COPY {{ project_slug }}/ ./{{ project_slug }}/
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --no-dev
uv sync --no-dev --no-editable

FROM python:{{ py.latest() }}-slim

COPY --from=builder /app/.venv /app/.venv

RUN useradd --no-create-home --shell /bin/false app
USER app

CMD ["uv", "run", "python", "-m", "{{ project_slug }}"]
CMD ["/app/.venv/bin/python", "-m", "{{ project_slug }}"]
{#- vim: set ft=dockerfile: #}
72 changes: 48 additions & 24 deletions tests/__snapshots__/test_dockerfile.ambr
Original file line number Diff line number Diff line change
@@ -1,139 +1,163 @@
# serializer version: 1
# name: test_workflows_container[3.12-3.10]
'''
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim AS builder

WORKDIR /app

# Install dependencies first (cached layer, only invalidated by pyproject.toml changes)
COPY pyproject.toml ./
COPY pyproject.toml README.md .
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --no-dev --no-install-project

# Copy source and install project
COPY pkfire/ ./pkfire/
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --no-dev
uv sync --no-dev --no-editable

FROM python:3.12-slim

COPY --from=builder /app/.venv /app/.venv

RUN useradd --no-create-home --shell /bin/false app
USER app

CMD ["uv", "run", "python", "-m", "pkfire"]
CMD ["/app/.venv/bin/python", "-m", "pkfire"]

'''
# ---
# name: test_workflows_container[3.12-3.12]
'''
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim AS builder

WORKDIR /app

# Install dependencies first (cached layer, only invalidated by pyproject.toml changes)
COPY pyproject.toml ./
COPY pyproject.toml README.md .
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --no-dev --no-install-project

# Copy source and install project
COPY pkfire/ ./pkfire/
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --no-dev
uv sync --no-dev --no-editable

FROM python:3.12-slim

COPY --from=builder /app/.venv /app/.venv

RUN useradd --no-create-home --shell /bin/false app
USER app

CMD ["uv", "run", "python", "-m", "pkfire"]
CMD ["/app/.venv/bin/python", "-m", "pkfire"]

'''
# ---
# name: test_workflows_container[3.14-3.10]
'''
FROM ghcr.io/astral-sh/uv:python3.14-bookworm-slim
FROM ghcr.io/astral-sh/uv:python3.14-bookworm-slim AS builder

WORKDIR /app

# Install dependencies first (cached layer, only invalidated by pyproject.toml changes)
COPY pyproject.toml ./
COPY pyproject.toml README.md .
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --no-dev --no-install-project

# Copy source and install project
COPY pkfire/ ./pkfire/
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --no-dev
uv sync --no-dev --no-editable

FROM python:3.14-slim

COPY --from=builder /app/.venv /app/.venv

RUN useradd --no-create-home --shell /bin/false app
USER app

CMD ["uv", "run", "python", "-m", "pkfire"]
CMD ["/app/.venv/bin/python", "-m", "pkfire"]

'''
# ---
# name: test_workflows_container[3.14-3.12]
'''
FROM ghcr.io/astral-sh/uv:python3.14-bookworm-slim
FROM ghcr.io/astral-sh/uv:python3.14-bookworm-slim AS builder

WORKDIR /app

# Install dependencies first (cached layer, only invalidated by pyproject.toml changes)
COPY pyproject.toml ./
COPY pyproject.toml README.md .
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --no-dev --no-install-project

# Copy source and install project
COPY pkfire/ ./pkfire/
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --no-dev
uv sync --no-dev --no-editable

FROM python:3.14-slim

COPY --from=builder /app/.venv /app/.venv

RUN useradd --no-create-home --shell /bin/false app
USER app

CMD ["uv", "run", "python", "-m", "pkfire"]
CMD ["/app/.venv/bin/python", "-m", "pkfire"]

'''
# ---
# name: test_workflows_container[No maximum-3.10]
'''
FROM ghcr.io/astral-sh/uv:python3.14-bookworm-slim
FROM ghcr.io/astral-sh/uv:python3.14-bookworm-slim AS builder

WORKDIR /app

# Install dependencies first (cached layer, only invalidated by pyproject.toml changes)
COPY pyproject.toml ./
COPY pyproject.toml README.md .
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --no-dev --no-install-project

# Copy source and install project
COPY pkfire/ ./pkfire/
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --no-dev
uv sync --no-dev --no-editable

FROM python:3.14-slim

COPY --from=builder /app/.venv /app/.venv

RUN useradd --no-create-home --shell /bin/false app
USER app

CMD ["uv", "run", "python", "-m", "pkfire"]
CMD ["/app/.venv/bin/python", "-m", "pkfire"]

'''
# ---
# name: test_workflows_container[No maximum-3.12]
'''
FROM ghcr.io/astral-sh/uv:python3.14-bookworm-slim
FROM ghcr.io/astral-sh/uv:python3.14-bookworm-slim AS builder

WORKDIR /app

# Install dependencies first (cached layer, only invalidated by pyproject.toml changes)
COPY pyproject.toml ./
COPY pyproject.toml README.md .
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --no-dev --no-install-project

# Copy source and install project
COPY pkfire/ ./pkfire/
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --no-dev
uv sync --no-dev --no-editable

FROM python:3.14-slim

COPY --from=builder /app/.venv /app/.venv

RUN useradd --no-create-home --shell /bin/false app
USER app

CMD ["uv", "run", "python", "-m", "pkfire"]
CMD ["/app/.venv/bin/python", "-m", "pkfire"]

'''
# ---
Loading