# Base image pinned by digest (multi-arch manifest list), verified against
# registry-1.docker.io 2026-11-18. A tag alone can be re-pointed; the digest
# cannot. To update the base image, fetch the new digest from Docker Hub
# and update this line (and the SBOM note in build-zip.py).
FROM python:3.12.16-slim@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b
# Apply current Debian security and point updates without removing packages.
# --with-new-pkgs permits required dependency additions while upgrade avoids removals.
# The pinned base digest keeps the starting point fixed; the resulting package
# versions must be recorded in the release SBOM for each build.
RUN apt-get update -o APT::Update::Error-Mode=any \
 && apt-get upgrade --with-new-pkgs -y --no-install-recommends \
 && apt-get clean \
 && rm -rf /var/lib/apt/lists/* \
 && chmod u-s /usr/bin/mount \
 && dpkg-statoverride --add --update root root 0700 /usr/bin/infocmp

# Update both the installed pip and the offline venv bootstrap in this pinned CPython.
ADD --checksum=sha256:f3b60b20ffaadd4415ed7957212a38ac63fa4c5fa375bd0f4a797777940fad13 --chmod=0644 https://files.pythonhosted.org/packages/07/25/ee8c38ae72d66b844ce8eb9711ba905dba21ca1a8a0c960057c41cd23337/pip-26.3-py3-none-any.whl /usr/local/lib/python3.12/ensurepip/_bundled/pip-26.3-py3-none-any.whl
RUN python -B - <<'PY'
import hashlib
import inspect
from pathlib import Path
import subprocess
import sys
import ensurepip

module = Path(inspect.getfile(ensurepip))
bundled = module.parent / "_bundled"
old = bundled / "pip-25.0.1-py3-none-any.whl"
new = bundled / "pip-26.3-py3-none-any.whl"
def digest(path):
    return hashlib.sha256(path.read_bytes()).hexdigest()

if sys.version_info[:3] != (3, 12, 16) or digest(module) != "90f6c76cd9ef7ed6daa198bb9ef771139683487f1b061211be7aa511831b2028":
    raise RuntimeError("Review the ensurepip bootstrap for this base image")
if digest(old) != "c46efd13b6aa8279f33f2864459c8ce587ea6a1a59ee20de055868d8f7688f7f" or digest(new) != "f3b60b20ffaadd4415ed7957212a38ac63fa4c5fa375bd0f4a797777940fad13":
    raise RuntimeError("Unexpected bootstrap wheel")
source = module.read_bytes()
previous = b'_PIP_VERSION = "25.0.1"'
assert source.count(previous) == 1
subprocess.run([sys.executable, "-m", "pip", "--isolated", "--disable-pip-version-check", "install",
                "--no-index", "--no-deps", "--no-cache-dir", str(new)], check=True)
module.write_bytes(source.replace(previous, b'_PIP_VERSION = "26.3"'))
old.unlink()
PY
ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1
WORKDIR /scanner
RUN groupadd --gid 10001 scanner && useradd --uid 10001 --gid 10001 --no-create-home scanner
COPY --chown=10001:10001 app ./app
USER 10001:10001
ENTRYPOINT ["python", "-m", "app"]
