# syntax=docker/dockerfile:1 # Stage 1: Build Vue frontend FROM node:22-alpine AS build-frontend WORKDIR /build COPY frontend/package.json frontend/package-lock.json* ./ RUN npm ci --quiet COPY frontend/ . RUN npm run build # Stage 2: Python runtime # Tracks CI image (ci-python:3.14) so test results stay representative. FROM python:3.14-slim AS runtime WORKDIR /app # Installed from uv.lock, exactly like CI, so the image runs the dependency # versions CI tested. RUN --mount=type=cache,target=/root/.cache/pip \ pip install --no-cache-dir uv # Dependencies before source, so the expensive layer is cached on every build # that doesn't change the lock. COPY pyproject.toml uv.lock ./ RUN --mount=type=cache,target=/root/.cache/uv \ uv sync --locked --no-dev --no-install-project COPY src/ src/ RUN --mount=type=cache,target=/root/.cache/uv \ uv sync --locked --no-dev # uv sync installs into a project venv rather than the system interpreter, so # alembic and hypercorn in CMD have to be found there. ENV PATH="/app/.venv/bin:$PATH" COPY --from=build-frontend /build/dist/ src/scribe/static/ COPY alembic.ini . COPY alembic/ alembic/ # Ensure Python finds the source tree (where static files live) before site-packages ENV PYTHONPATH=/app/src # Three values kept separate, plus the commit: # BUILD_VERSION is the name (YYYY.MM.DD.HHMM from commit time), the same on # every lane for the same source. # BUILD_KEY is the ordering key (minutes since 2020-01-01 from build time), the # only value compared to decide which build is newer. # BUILD_CHANNEL is its own field, never part of the name. # BUILD_COMMIT lets the image's self-report be checked against its : tag. # A local build leaves the key and channel empty: it has no place in an update # order, and /api/version omits them. ARG BUILD_VERSION=dev ARG BUILD_KEY= ARG BUILD_CHANNEL= ARG BUILD_COMMIT= ENV APP_VERSION=$BUILD_VERSION ENV APP_BUILD_KEY=$BUILD_KEY ENV APP_CHANNEL=$BUILD_CHANNEL ENV APP_COMMIT=$BUILD_COMMIT EXPOSE 5000 CMD ["sh", "-c", "alembic upgrade head && hypercorn 'scribe.app:create_app()' --bind 0.0.0.0:5000 --keep-alive 600"]