FROM ubuntu:24.04@sha256:4fbb8e6a8395de5a7550b33509421a2bafbc0aab6c06ba2cef9ebffbc7092d90

ARG DEBIAN_FRONTEND=noninteractive
ARG UBUNTU_SNAPSHOT=20260901T000000Z
# Digest-pinned base has no CA bundle. Bootstrap it from the GPG-signed
# snapshot, then restore TLS verification before fetching the toolchain.
RUN sed -i \
      -e "s|http://archive.ubuntu.com/ubuntu/|https://snapshot.ubuntu.com/ubuntu/${UBUNTU_SNAPSHOT}/|g" \
      -e "s|http://security.ubuntu.com/ubuntu/|https://snapshot.ubuntu.com/ubuntu/${UBUNTU_SNAPSHOT}/|g" \
      /etc/apt/sources.list.d/ubuntu.sources \
    && printf 'Acquire::Check-Valid-Until "false";\n' > /etc/apt/apt.conf.d/99snapshot \
    && printf 'Acquire::https::Verify-Peer "false";\n' > /etc/apt/apt.conf.d/98snapshot-ca-bootstrap \
    && apt-get update && apt-get install -y --no-install-recommends ca-certificates \
    && rm /etc/apt/apt.conf.d/98snapshot-ca-bootstrap \
    && apt-get update && apt-get install -y --no-install-recommends \
    autoconf automake build-essential curl \
    mingw-w64 nasm pkg-config xz-utils \
    && rm -rf /var/lib/apt/lists/*

COPY build-minimal.sh /usr/local/bin/build-minimal.sh
RUN sed -i 's/\r$//' /usr/local/bin/build-minimal.sh \
    && chmod 0755 /usr/local/bin/build-minimal.sh

ENTRYPOINT ["/usr/local/bin/build-minimal.sh"]
