# SPDX-License-Identifier: GPL-3.0-or-later
# Build environment for a portable Linux build (tools/linux/build.sh --container): glibc 2.35, so
# the game runs on SteamOS 3 and any current distribution, with a recent clang and GCC 13's
# libstdc++ (the Dawn prebuilt needs it; the game links it statically), and the .NET 10 SDK.
# Contains no game data.
FROM docker.io/library/ubuntu:22.04

ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
        ca-certificates curl gnupg software-properties-common lsb-release \
    && add-apt-repository -y ppa:ubuntu-toolchain-r/test \
    && curl -fsSL https://apt.llvm.org/llvm-snapshot.gpg.key | gpg --dearmor -o /usr/share/keyrings/llvm.gpg \
    && echo "deb [signed-by=/usr/share/keyrings/llvm.gpg] http://apt.llvm.org/jammy/ llvm-toolchain-jammy-20 main" \
        > /etc/apt/sources.list.d/llvm.list \
    && apt-get update && apt-get install -y --no-install-recommends \
        clang-20 lld-20 llvm-20 g++-13 libstdc++-13-dev \
        git python3 python3-pip ninja-build pkg-config make file xz-utils \
        libicu70 \
        libpipewire-0.3-dev libpulse-dev libasound2-dev libjack-jackd2-dev \
        libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev libxss-dev \
        libxtst-dev libxkbcommon-dev libxinerama-dev libwayland-dev wayland-protocols libdecor-0-dev \
        libegl-dev libgl-dev libvulkan-dev libdrm-dev libgbm-dev libudev-dev libdbus-1-dev \
        libusb-1.0-0-dev libibus-1.0-dev \
        libpng-dev zlib1g-dev libfreetype-dev \
    && python3 -m pip install --no-cache-dir 'cmake==3.31.6' \
    && rm -rf /var/lib/apt/lists/*

# .NET 10 SDK: builds PowerUp+ (net10.0) and runs the translator (net8.0, with DOTNET_ROLL_FORWARD).
RUN curl -fsSL https://dot.net/v1/dotnet-install.sh -o /tmp/dotnet-install.sh \
    && bash /tmp/dotnet-install.sh --channel 10.0 --install-dir /usr/share/dotnet \
    && ln -s /usr/share/dotnet/dotnet /usr/local/bin/dotnet && rm /tmp/dotnet-install.sh
ENV DOTNET_ROOT=/usr/share/dotnet

RUN ln -s /usr/bin/clang-20 /usr/local/bin/clang && ln -s /usr/bin/clang++-20 /usr/local/bin/clang++ \
    && ln -s /usr/bin/ld.lld-20 /usr/local/bin/ld.lld && ln -s /usr/bin/llvm-ar-20 /usr/local/bin/llvm-ar \
    && ln -s /usr/bin/llvm-ranlib-20 /usr/local/bin/llvm-ranlib
