# po-sco 2 toolchain image: ASan + UBSan builds of the new engine.
#
# Base: Debian 13 (trixie) slim, pinned by digest. apt reads the snapshot.debian.org state that
# the base image itself was built from (its debian.sources names 20261020T213255Z), so a rebuild
# resolves the same packages. The versions are also pinned explicitly: if they ever drift, the
# build fails instead of silently changing the compiler.
#
# Build and use it through cmake/toolchain/posco-toolchain.sh (bump TOOLCHAIN_TAG there when this
# file changes).
FROM docker.io/library/debian@sha256:4876fdea29cac1a33a3195f1eb1952feb1fca7dd6dd00be3e2f1879cf20d34d2

ARG SNAPSHOT=20261020T213255Z

RUN printf '%s\n' \
      'Types: deb' \
      "URIs: http://snapshot.debian.org/archive/debian/${SNAPSHOT}" \
      'Suites: trixie trixie-updates' \
      'Components: main' \
      'Signed-By: /usr/share/keyrings/debian-archive-keyring.pgp' \
      '' \
      'Types: deb' \
      "URIs: http://snapshot.debian.org/archive/debian-security/${SNAPSHOT}" \
      'Suites: trixie-security' \
      'Components: main' \
      'Signed-By: /usr/share/keyrings/debian-archive-keyring.pgp' \
      > /etc/apt/sources.list.d/debian.sources \
 && apt-get -o Acquire::Check-Valid-Until=false update \
 && apt-get install -y --no-install-recommends \
      g++=4:14.2.0-1 g++-14=14.2.0-19 gcc-14=14.2.0-19 \
      libasan8=14.2.0-19 libubsan1=14.2.0-19 \
      cmake=3.31.6-2 ninja-build=1.12.1-1 \
 && rm -rf /var/lib/apt/lists/* \
 && dpkg-query -W -f '${Package} ${Version}\n' \
      g++ g++-14 libasan8 libubsan1 libstdc++6 libc6 cmake ninja-build \
      > /posco-toolchain-packages.txt

ENV CMAKE_GENERATOR=Ninja

LABEL org.opencontainers.image.title="posco-toolchain" \
      org.opencontainers.image.description="Pinned GCC 14 / CMake 3.31 toolchain for ASan+UBSan builds of po-sco 2"
