Supply repository scripts as a named build context for the backend check stage so containerized regression tests can import the same acceptance helpers as local tests. Keep operator scripts out of the runtime image.
34 lines
1.9 KiB
Docker
34 lines
1.9 KiB
Docker
FROM python:3.13-slim AS base
|
|
COPY --from=ghcr.io/astral-sh/uv:0.12 /uv /uvx /usr/local/bin/
|
|
ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy UV_NO_CACHE=1 UV_PROJECT_ENVIRONMENT=/opt/venv PATH=/opt/venv/bin:$PATH
|
|
WORKDIR /app
|
|
COPY pyproject.toml uv.lock ./
|
|
# Keep Playwright's bundled driver separate from the remaining Python dependencies.
|
|
RUN uv sync --locked --no-dev --no-install-project --no-install-package playwright
|
|
RUN uv sync --locked --no-dev --no-install-project
|
|
COPY . .
|
|
RUN uv sync --locked --no-dev
|
|
|
|
FROM base AS check
|
|
COPY --from=project-scripts . /scripts/
|
|
RUN uv sync --locked && uv run pytest && uvx ruff==0.14.14 check --select F,E9,B src tests
|
|
|
|
FROM base AS browser-download
|
|
ENV PLAYWRIGHT_BROWSERS_PATH=/opt/ms-playwright
|
|
RUN playwright install --only-shell chromium
|
|
# The executable alone nearly fills the CDN budget; copy its assets in another layer.
|
|
RUN python -c 'from pathlib import Path; root = Path("/opt/ms-playwright"); binary, = root.glob("chromium_headless_shell-*/chrome-headless-shell-linux64/chrome-headless-shell"); target = Path("/opt/browser-executable") / binary.relative_to(root); target.parent.mkdir(parents=True); binary.rename(target)'
|
|
|
|
FROM base AS runtime
|
|
ENV PLAYWRIGHT_BROWSERS_PATH=/opt/ms-playwright
|
|
# Split graphics libraries from the remaining browser libraries and fonts.
|
|
RUN apt-get update && apt-get install -y --no-install-recommends libgbm1 && rm -rf /var/lib/apt/lists/*
|
|
RUN playwright install-deps chromium && rm -rf /var/lib/apt/lists/*
|
|
COPY --from=browser-download /opt/browser-executable/ /opt/ms-playwright/
|
|
COPY --from=browser-download /opt/ms-playwright/ /opt/ms-playwright/
|
|
ARG APP_VERSION=source
|
|
ARG APP_COMMIT=unknown
|
|
ENV APP_VERSION=$APP_VERSION APP_COMMIT=$APP_COMMIT
|
|
LABEL org.opencontainers.image.version=$APP_VERSION org.opencontainers.image.revision=$APP_COMMIT
|
|
LABEL org.opencontainers.image.source=https://git.134333.xyz/eezd/AlphaPulse
|