|
| 1 | +# syntax=docker/dockerfile:1.7 |
| 2 | + |
| 3 | +############################################### |
| 4 | +# QEMU STATIC (lets x86_64 run arm64 userland) |
| 5 | +############################################### |
| 6 | +FROM multiarch/qemu-user-static:latest AS qemu |
| 7 | + |
| 8 | +############################################### |
| 9 | +# BUILDER (Alpine) -> bootstrap ArchLinuxARM rootfs |
| 10 | +############################################### |
| 11 | +FROM alpine:3.20 AS builder |
| 12 | + |
| 13 | +RUN apk add --no-cache \ |
| 14 | + pacman \ |
| 15 | + arch-install-scripts \ |
| 16 | + gnupg \ |
| 17 | + curl \ |
| 18 | + xz \ |
| 19 | + zstd \ |
| 20 | + tar \ |
| 21 | + ca-certificates |
| 22 | + |
| 23 | +ENV OUT=/out |
| 24 | +ENV PAC=/work/pacman |
| 25 | +RUN mkdir -p ${OUT} ${OUT}/var/lib/pacman ${PAC}/cache ${PAC}/log ${PAC}/gnupg /etc/pacman.d |
| 26 | + |
| 27 | +# --- Pacman config targeting ArchLinuxARM (aarch64) --- |
| 28 | +# IMPORTANT: DBPath points INSIDE the target rootfs so installed packages are registered there. |
| 29 | +RUN cat > /etc/pacman.conf <<'EOF' |
| 30 | +[options] |
| 31 | +RootDir = /out |
| 32 | +DBPath = /out/var/lib/pacman |
| 33 | +CacheDir = /work/pacman/cache |
| 34 | +LogFile = /work/pacman/log/pacman.log |
| 35 | +GPGDir = /work/pacman/gnupg |
| 36 | +Architecture = aarch64 |
| 37 | +ParallelDownloads = 5 |
| 38 | +# Optional in containers: |
| 39 | +CheckSpace |
| 40 | +# First pass without signatures (to fetch the keyring) |
| 41 | +SigLevel = Never |
| 42 | + |
| 43 | +[core] |
| 44 | +Server = http://mirror.archlinuxarm.org/$arch/$repo |
| 45 | +[extra] |
| 46 | +Server = http://mirror.archlinuxarm.org/$arch/$repo |
| 47 | +[community] |
| 48 | +Server = http://mirror.archlinuxarm.org/$arch/$repo |
| 49 | +EOF |
| 50 | + |
| 51 | +# --- Bootstrap: fetch ALARM keyring with sigs disabled --- |
| 52 | +RUN pacman --config /etc/pacman.conf -Sy --noconfirm archlinuxarm-keyring |
| 53 | + |
| 54 | +# Initialize host keyring to trust ArchLinuxARM keys for the *builder* pacman |
| 55 | +RUN mkdir -p /usr/share/pacman/keyrings && \ |
| 56 | + cp -av ${OUT}/usr/share/pacman/keyrings/* /usr/share/pacman/keyrings/ && \ |
| 57 | + pacman-key --gpgdir ${PAC}/gnupg --init && \ |
| 58 | + pacman-key --gpgdir ${PAC}/gnupg --populate archlinuxarm |
| 59 | + |
| 60 | +# Harden pacman to require signatures now (builder pacman) |
| 61 | +RUN sed -i 's/^SigLevel.*/SigLevel = Required DatabaseOptional/' /etc/pacman.conf $OUT/etc/pacman.conf |
| 62 | +RUN sed -i 's/#DisableSandbox/DisableSandbox/' /etc/pacman.conf $OUT/etc/pacman.conf |
| 63 | + |
| 64 | +# --- Install the userland into /out (DB gets written to /out/var/lib/pacman) --- |
| 65 | +# NOTE: explicitly include bash (base alone may not provide it) |
| 66 | +RUN pacman --config /etc/pacman.conf -Syu --noconfirm base zsh |
| 67 | + |
| 68 | +RUN printf 'nameserver 1.1.1.1\nnameserver 1.0.0.1\noptions edns0\n' > /etc/resolv.conf || true |
| 69 | + |
| 70 | +# Optional locale scaffolding |
| 71 | +RUN echo "en_US.UTF-8 UTF-8" > ${OUT}/etc/locale.gen && \ |
| 72 | + echo "LANG=en_US.UTF-8" > ${OUT}/etc/locale.conf || true |
| 73 | + |
| 74 | +# Slim down (remove sync dbs, keep local db intact under /out/var/lib/pacman/local) |
| 75 | +RUN rm -rf ${PAC}/cache/* ${OUT}/var/lib/pacman/sync/* |
| 76 | + |
| 77 | +# Optional: export rootfs tarball artifact |
| 78 | +RUN tar -C ${OUT} -cpf /archlinuxarm-aarch64-rootfs.tar . |
| 79 | + |
| 80 | +############################################### |
| 81 | +# FINAL: runnable ArchLinuxARM rootfs (aarch64) |
| 82 | +############################################### |
| 83 | +FROM scratch AS archarm |
| 84 | +# qemu static so this runs on x86_64 (requires binfmt installed on host) |
| 85 | +COPY --from=qemu /usr/bin/qemu-aarch64-static /usr/bin/qemu-aarch64-static |
| 86 | +# the Arch ARM rootfs (with local pacman DB inside it) |
| 87 | +COPY --from=builder /out/ / |
| 88 | + |
| 89 | +ENV LANG=en_US.UTF-8 \ |
| 90 | + PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin |
| 91 | + |
| 92 | +CMD ["/usr/bin/zsh"] |
| 93 | + |
| 94 | +############################################### |
| 95 | +# EXPORT-ONLY: tarball artifact stage |
| 96 | +############################################### |
| 97 | +FROM scratch AS export |
| 98 | +COPY --from=builder /archlinuxarm-aarch64-rootfs.tar /archlinuxarm-aarch64-rootfs.tar |
0 commit comments