Bring the application, own tests, Dockerfile, toolchain, compose stack,
HAProxy, k6 and RustFS configuration, migrations, hooks, evidence and
scenario scripts and the CI job from the lab 4 solution commit d2744bc,
merge the lab 4 Makefile targets into the lab 5 skeleton Makefile
without touching its targets, and append the lab 4 solution variables
to the skeleton .env.example. The package and the application follow
the contract version 1.5.0, and the image and the throwaway test
containers are tagged lab5 so they do not collide with a lab 4 stand on
the same host.
This is the starting point of the lab 5 cycle: lint, own tests and the
offline skeleton check pass before any lab 5 change.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
49 lines
1.5 KiB
Docker
49 lines
1.5 KiB
Docker
FROM python:3.14-slim-trixie@sha256:51dafde81dbdb6ebde285137a295cf18a47ca95234fe388a343719cb97305b3d AS builder
|
|
|
|
COPY --from=ghcr.io/astral-sh/uv:0.9.7@sha256:ba4857bf2a068e9bc0e64eed8563b065908a4cd6bfb66b531a9c424c8e25e142 /uv /usr/local/bin/uv
|
|
|
|
ENV UV_COMPILE_BYTECODE=1 \
|
|
UV_LINK_MODE=copy \
|
|
UV_PYTHON_DOWNLOADS=never \
|
|
UV_PROJECT_ENVIRONMENT=/opt/venv
|
|
|
|
WORKDIR /build
|
|
|
|
COPY pyproject.toml uv.lock README.md ./
|
|
RUN uv sync --locked --no-dev --no-install-project --no-editable
|
|
|
|
COPY src ./src
|
|
RUN uv sync --locked --no-dev --no-editable
|
|
|
|
|
|
FROM python:3.14-slim-trixie@sha256:51dafde81dbdb6ebde285137a295cf18a47ca95234fe388a343719cb97305b3d AS runtime
|
|
|
|
ENV PYTHONUNBUFFERED=1 \
|
|
PYTHONDONTWRITEBYTECODE=1 \
|
|
PATH="/opt/venv/bin:$PATH" \
|
|
HOST=0.0.0.0 \
|
|
PORT=8080 \
|
|
LOG_LEVEL=INFO \
|
|
WEB_CONCURRENCY=2 \
|
|
REQUEST_TIMEOUT_SECONDS=8 \
|
|
DRAIN_SECONDS=2 \
|
|
SHUTDOWN_TIMEOUT_SECONDS=5
|
|
|
|
RUN groupadd --system --gid 10001 messenger \
|
|
&& useradd --system --uid 10001 --gid messenger --no-create-home --shell /usr/sbin/nologin messenger
|
|
|
|
COPY --from=builder --chown=root:root /opt/venv /opt/venv
|
|
|
|
WORKDIR /app
|
|
|
|
USER 10001:10001
|
|
|
|
EXPOSE 8080
|
|
|
|
HEALTHCHECK --interval=10s --timeout=3s --start-period=5s --retries=3 \
|
|
CMD ["python", "-c", "import urllib.request,sys;sys.exit(0 if urllib.request.urlopen('http://127.0.0.1:8080/health/live',timeout=2).status==200 else 1)"]
|
|
|
|
CMD ["python", "-m", "gunicorn", \
|
|
"--config", "python:messenger.gunicorn_conf", \
|
|
"messenger.main:create_app()"]
|