# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: Copyright (C) 2026 Max A. Vilkki a.k.a. codise
#
# The Linux release build (scripts/release-linux.sh, DESIGN §2.2): Ubuntu 20.04, so the
# binary needs no newer glibc than 2.31 and runs on distributions from about 2020 on. The
# compiler is GCC 13 from the toolchain PPA, since 20.04's own GCC 10 is the floor the code
# keeps to but not what it's tested with; libstdc++ and libgcc are linked statically
# (LDFLAGS in build.sh), so the newer libstdc++ isn't needed at run time. CMake comes from
# Kitware's release (20.04 has 3.16; the presets need 3.25), checked against its SHA-256 list.

FROM docker.io/library/ubuntu:20.04

ARG CMAKE_VERSION=3.31.6
ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get install -y --no-install-recommends \
        ca-certificates curl git gnupg software-properties-common \
    && add-apt-repository -y ppa:ubuntu-toolchain-r/test \
    && apt-get update && apt-get install -y --no-install-recommends \
        gcc-13 g++-13 make ninja-build pkg-config python3 \
        libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxi-dev libxfixes-dev \
        libxss-dev libxtst-dev libxkbcommon-dev libwayland-dev wayland-protocols \
        libegl1-mesa-dev libgl1-mesa-dev libdbus-1-dev libdrm-dev libgbm-dev \
    && rm -rf /var/lib/apt/lists/*

RUN arch="$(uname -m)" \
    && cd /tmp \
    && curl -fsSLO "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-${arch}.tar.gz" \
    && curl -fsSLO "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-SHA-256.txt" \
    && grep "cmake-${CMAKE_VERSION}-linux-${arch}.tar.gz" "cmake-${CMAKE_VERSION}-SHA-256.txt" | sha256sum -c - \
    && tar -xzf "cmake-${CMAKE_VERSION}-linux-${arch}.tar.gz" -C /opt \
    && ln -s "/opt/cmake-${CMAKE_VERSION}-linux-${arch}/bin/"* /usr/local/bin/ \
    && rm -f /tmp/cmake-*

ENV CC=gcc-13 CXX=g++-13
