FROM docker.io/library/alpine:edge

RUN apk upgrade --no-cache && \
    apk add --no-cache \
    alpine-sdk \
    apk-tools \
    autoconf \
    automake \
    bash \
    bc \
    bison \
    bzip2 \
    ca-certificates \
    cmake \
    coreutils \
    curl \
    file \
    findutils \
    flex \
    gettext-dev \
    git \
    gzip \
    elfutils-dev \
    gmp-dev \
    mpfr-dev \
    mpc1-dev \
    libtool \
    linux-headers \
    meson \
    ninja \
    openssl \
    openssl-dev \
    patch \
    pkgconf \
    python3 \
    tar \
    texinfo \
    xz \
    zstd

RUN rm -rf /tmp/mkpkg-root /tmp/distro-preflight.apk /tmp/APKINDEX.adb /tmp/distro-preflight.rsa && \
    openssl genrsa -out /tmp/distro-preflight.rsa 2048 >/dev/null 2>&1 && \
    openssl rsa -in /tmp/distro-preflight.rsa -pubout -out /etc/apk/keys/distro-preflight.rsa.pub >/dev/null 2>&1 && \
    mkdir -p /tmp/mkpkg-root/usr/share/distro && \
    printf ok > /tmp/mkpkg-root/usr/share/distro/preflight && \
    apk --sign-key /tmp/distro-preflight.rsa mkpkg \
    --files /tmp/mkpkg-root \
    --output /tmp/distro-preflight.apk \
    --info name:distro-preflight \
    --info version:0-r0 \
    --info arch:noarch \
    --info description:preflight \
    --info license:MIT >/dev/null && \
    apk --sign-key /tmp/distro-preflight.rsa mkndx -o /tmp/APKINDEX.adb /tmp/distro-preflight.apk >/dev/null && \
    test -s /tmp/distro-preflight.apk && \
    test -s /tmp/APKINDEX.adb

WORKDIR /work
