# Installer-environment container for bootc-image-builder's `bootc-installer`
# image type. This is NOT the quine-linux OS -- it's the throwaway Anaconda
# environment the ISO boots into, which then installs the real quine-linux
# bootc image (passed separately via --bootc-installer-payload-ref). See
# docs/patched-anaconda-installer.md for the full workflow this fits into.

FROM quay.io/fedora/fedora-bootc:rawhide

# URL of a dnf .repo file for the repository holding a build of the patched
# anaconda-webui fork -- by default the Forgejo RPM registry its CI publishes
# to (see docs/patched-anaconda-installer.md). Override at build time with
# --build-arg RPM_REPO_URL=...; empty means stock Fedora anaconda-webui.
ARG RPM_REPO_URL
# Set by the Taskfile to the repo metadata's checksum; only here so a newly
# published RPM invalidates the build cache for the layer below.
ARG RPM_REPO_REV

# priority=10 (default 99) makes dnf take anaconda-webui from that repo even
# when Fedora's own build is newer. Forgejo signs the repo metadata but not
# the RPMs themselves, so verify the signed metadata (which carries each
# package's checksum) instead of per-package signatures.
RUN set -eux; \
    echo "anaconda-webui repo rev: ${RPM_REPO_REV:-none}"; \
    if [ -n "${RPM_REPO_URL}" ]; then \
      curl -fsSL "${RPM_REPO_URL}" -o /etc/yum.repos.d/quine-anaconda.repo; \
      sed -i 's/^gpgcheck=.*/gpgcheck=0/' /etc/yum.repos.d/quine-anaconda.repo; \
      printf '\nrepo_gpgcheck=1\npriority=10\n' >> /etc/yum.repos.d/quine-anaconda.repo; \
    fi; \
    dnf install -y \
      anaconda-webui \
      anaconda \
      anaconda-install-env-deps \
      anaconda-dracut \
      dracut-config-generic \
      dracut-network \
      net-tools \
      squashfs-tools \
      grub2-efi-x64-cdboot \
      python3-mako \
      lorax-templates-generic \
      biosdevname \
      prefixdevname; \
    dnf clean all

# Fedora 43+ path fixup -- image-builder expects the EFI directory under
# /boot/efi, not wherever the fedora-bootc base puts it.
RUN mkdir -p /boot/efi && cp -ra /usr/lib/efi/*/*/EFI /boot/efi

# lorax wants to symlink /mnt -> /var/mnt, which doesn't exist on this base.
RUN mkdir -p /var/mnt
