FROM stagex/busybox AS busybox FROM stagex/musl AS musl FROM stagex/xorriso AS xorriso FROM stagex/syslinux AS syslinux FROM stagex/cpio AS cpio FROM stagex/linux-airgap AS linux FROM stagex/mtools AS mtools FROM stagex/xz AS xz FROM stagex/grub:local AS grub FROM scratch AS base COPY --from=busybox . / COPY --from=musl . / COPY --from=xorriso . / COPY --from=cpio . / COPY --from=mtools . / COPY --from=linux . / COPY --from=syslinux . / COPY --from=xz . / COPY --from=grub . / FROM base AS build ## Kernel COPY --from=linux /bzImage iso/boot/vmlinuz ## Initramfs COPY --from=stagex/busybox . initramfs COPY --chmod=0755 <<-EOF initramfs/init #!/bin/sh /bin/sh EOF RUN <<-EOF set -eux cd initramfs find . \ | cpio -o -H newc \ | gzip -9 \ > ../iso/boot/initramfs EOF ## Grub (EFI Boot) COPY <<-EOF iso/boot/grub/grub.cfg menuentry "Linux Airgap" { linux /boot/vmlinuz initrd /boot/initramfs } EOF COPY <<-EOF grub_early.cfg search --no-floppy --set=root --label "Airgap" set prefix=(\$root)/boot/grub EOF RUN <<-EOF set -eux mkdir -p iso/efi/boot grub-mkimage \ --config="grub_early.cfg" \ --prefix="/boot/grub" \ --output="iso/efi/boot/bootx64.efi" \ --format="x86_64-efi" \ --compression="xz" \ all_video \ disk \ part_gpt \ part_msdos \ linux \ normal \ configfile \ search \ search_label \ efi_gop \ fat \ iso9660 \ cat \ echo \ ls \ test \ true \ help \ gzio EOF RUN <<-EOF mformat -i iso/boot/grub/efi.img -C -f 1440 -N 0 :: mcopy -i iso/boot/grub/efi.img iso/efi touch -md "@0" iso/boot/grub/efi.img EOF ## Syslinux (BIOS Boot) COPY <<-EOF iso/boot/syslinux/syslinux.cfg TIMEOUT 2 PROMPT -1 DEFAULT Airgap LABEL Airgap MENU LABEL Linux Airgap KERNEL /boot/vmlinuz INITRD /boot/initramfs EOF RUN <<-EOF mkdir -p iso/boot/syslinux for file in \ isohdpfx.bin \ isolinux.bin \ ldlinux.c32 \ libutil.c32 \ libcom32.c32 \ mboot.c32; \ do mv /usr/share/syslinux/$file iso/boot/syslinux/$file || return 1 done EOF ## Build Hybrid EFI/BIOS ISO FROM build AS install RUN xorrisofs \ -output airgap.iso \ -full-iso9660-filenames \ -joliet \ -rational-rock \ -sysid LINUX \ -isohybrid-mbr iso/boot/syslinux/isohdpfx.bin \ -eltorito-boot boot/syslinux/isolinux.bin \ -eltorito-catalog boot/syslinux/boot.cat \ -no-emul-boot \ -boot-load-size 4 \ -boot-info-table \ -eltorito-alt-boot \ -e boot/grub/efi.img \ -no-emul-boot \ -isohybrid-gpt-basdat \ -follow-links \ iso/ FROM scratch AS package COPY --from=install /iso /iso COPY --from=install /airgap.iso /