soapbox/Containerfile
Ole-Morten Duesund d2e45fb6c9 Containerfile: STOPSIGNAL SIGINT så waitress avslutter rent
podman stop tok 10 s og endte i SIGKILL fordi waitress ignorerer SIGTERM
som PID 1. Med SIGINT stopper containeren på under et halvt sekund.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JcEy43fNYpwg6K6oTKakWR
2026-08-26 12:14:10 +02:00

37 lines
1.4 KiB
Docker
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Soapbox lettest mulig image: python:alpine + git + appen.
# Bygg (fra repo-rot):
# BUILDAH_FORMAT=docker podman build \
# --build-arg BUILD_DATE="$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
# --build-arg GIT_REVISION="$(git describe --always --dirty)" \
# -t soapbox .
FROM python:3.13-alpine AS build
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
WORKDIR /app
ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy UV_PYTHON_DOWNLOADS=never
COPY pyproject.toml uv.lock README.md ./
RUN uv sync --frozen --no-dev --no-install-project
COPY soapbox ./soapbox
RUN uv sync --frozen --no-dev
FROM python:3.13-alpine
ARG BUILD_DATE
ARG GIT_REVISION
LABEL org.opencontainers.image.title="soapbox" \
org.opencontainers.image.created="${BUILD_DATE}" \
org.opencontainers.image.revision="${GIT_REVISION}"
RUN apk add --no-cache git curl \
&& printf 'build_date=%s\ngit_revision=%s\n' "${BUILD_DATE}" "${GIT_REVISION}" > /etc/build-info \
&& adduser -D -u 1000 soapbox \
&& mkdir -p /data && chown soapbox:soapbox /data
WORKDIR /app
COPY --from=build --chown=soapbox:soapbox /app /app
USER soapbox
ENV PATH="/app/.venv/bin:$PATH" \
SOAPBOX_DATA_DIR=/data \
PYTHONUNBUFFERED=1
VOLUME /data
EXPOSE 8080
# waitress avslutter rent på SIGINT; SIGTERM ignoreres når den kjører som PID 1.
STOPSIGNAL SIGINT
HEALTHCHECK --interval=30s --timeout=3s CMD curl -fsS http://localhost:8080/ >/dev/null || exit 1
CMD ["soapbox", "serve"]