# Build image for the AfterAPro Linux release artifacts (.deb and AppImage).
#
# Adapted from Fissure's and Sketchr's. The base is Debian 13 "trixie" by
# default (ARG BASE_IMAGE). The binary links the build distribution's glibc,
# and glibc is only backward compatible, so a trixie build runs on trixie and
# newer. The .deb's Depends are computed from the build distribution's package
# names by deb-depends.sh, so they are right for that release and no other.
# For an older target, at the cost of an older toolchain:
#   BASE_IMAGE=debian:bookworm-slim make docker-build     # Debian 12
#
# The image holds the toolchain and the build dependencies only. The AfterAPro
# and nilorea-library trees are mounted at run time by docker-build.sh, which
# runs `make deb appimage` inside.
ARG BASE_IMAGE=debian:trixie-slim
FROM ${BASE_IMAGE}

ENV DEBIAN_FRONTEND=noninteractive

# The build dependencies docs/dev/BUILDING.md lists, lensfun, libxml2 and
# lcms2 included so the release carries lens corrections, XMP files and soft
# proofing, plus what
# packaging needs: dpkg-dev for dpkg-deb, binutils for readelf (both in
# build-essential), librsvg2-bin to rasterise the icon, curl and
# ca-certificates to fetch appimagetool, and file, which appimagetool runs.
RUN apt-get update && apt-get install -y --no-install-recommends \
        build-essential pkg-config curl ca-certificates file dpkg-dev \
        liballegro5-dev liballegro-image5-dev liballegro-ttf5-dev \
        liballegro-dialog5-dev \
        libsqlite3-dev libjpeg-dev libpng-dev zlib1g-dev libx11-dev \
        liblensfun-dev libxml2-dev liblcms2-dev \
        librsvg2-bin \
    && rm -rf /var/lib/apt/lists/*

# appimagetool is itself an AppImage. Without FUSE, which an unprivileged
# container does not have, it has to extract itself and run instead.
ENV APPIMAGE_EXTRACT_AND_RUN=1

WORKDIR /build/AfterAPro
