|
| 1 | +FROM ghcr.io/devducks/archlinuxarm-basic:latest AS builder |
| 2 | + |
| 3 | +ARG KERNEL |
| 4 | +ARG SERIAL_TTY=ttyAMA1 |
| 5 | + |
| 6 | +RUN pacman-key --init && pacman-key --populate archlinuxarm |
| 7 | + |
| 8 | +RUN pacman -Syu --noconfirm |
| 9 | + |
| 10 | +# Install now the linux-rpi (Kernel for RPi) |
| 11 | +RUN pacman -Sy ${KERNEL} openssh --noconfirm |
| 12 | + |
| 13 | +# Prepare network to be started with systemd-networkd with dhcp |
| 14 | +RUN mkdir -p /etc/systemd/network && \ |
| 15 | + mkdir -p /etc/systemd/system/network-online.target.wants && \ |
| 16 | + mkdir -p /etc/systemd/system/sysinit.target.wants |
| 17 | + |
| 18 | +RUN printf '[Match]\nName=en*\n\n[Network]\nDHCP=yes\nDNSSEC=no\n' > /etc/systemd/network/en.network && \ |
| 19 | + printf '[Match]\nName=eth*\n\n[Network]\nDHCP=yes\nDNSSEC=no\n' > /etc/systemd/network/eth.network |
| 20 | + |
| 21 | +RUN ln -sf /usr/lib/systemd/system/systemd-networkd.service /etc/systemd/system/dbus-org.freedesktop.network1.service && \ |
| 22 | + ln -sf /usr/lib/systemd/system/systemd-resolved.service /etc/systemd/system/dbus-org.freedesktop.resolve1.service && \ |
| 23 | + ln -sf /usr/lib/systemd/system/systemd-timesyncd.service /etc/systemd/system/dbus-org.freedesktop.timesync1.service && \ |
| 24 | + ln -sf /usr/lib/systemd/system/systemd-networkd.service /etc/systemd/system/multi-user.target.wants/systemd-networkd.service && \ |
| 25 | + ln -sf /usr/lib/systemd/system/systemd-networkd.socket /etc/systemd/system/sockets.target.wants/systemd-networkd.socket && \ |
| 26 | + ln -sf /usr/lib/systemd/system/systemd-network-generator.service /etc/systemd/system/sysinit.target.wants/systemd-network-generator.service && \ |
| 27 | + ln -sf /usr/lib/systemd/system/systemd-networkd-wait-online.service /etc/systemd/system/network-online.target.wants/systemd-networkd-wait-online.service |
| 28 | + |
| 29 | +RUN mkdir -p /etc/ssh/sshd_config.d && \ |
| 30 | + printf '%s\n' \ |
| 31 | + 'PermitRootLogin yes' \ |
| 32 | + 'PasswordAuthentication yes' \ |
| 33 | + 'UsePAM yes' \ |
| 34 | + 'ChallengeResponseAuthentication no' \ |
| 35 | + 'KbdInteractiveAuthentication no' \ |
| 36 | + 'X11Forwarding no' \ |
| 37 | + 'PrintMotd no' \ |
| 38 | + 'ClientAliveInterval 120' \ |
| 39 | + 'ClientAliveCountMax 2' \ |
| 40 | + > /etc/ssh/sshd_config.d/10-root-password.conf |
| 41 | + |
| 42 | +# Set root password interactively or fixed |
| 43 | +# (replace "changeme" with your actual password) |
| 44 | +RUN echo "root:alarm" | chpasswd |
| 45 | + |
| 46 | +RUN ln -sf /usr/lib/systemd/system/sshd.service /etc/systemd/system/multi-user.target.wants/sshd.service |
| 47 | + |
| 48 | +# Cleanup pacman-key init |
| 49 | +RUN rm -rf /etc/pacman.d/gnupg* |
| 50 | + |
| 51 | +# Create rootfs |
| 52 | +RUN tar -cpf /rootfs.tar \ |
| 53 | + --numeric-owner --xattrs --acls --one-file-system \ |
| 54 | + --sort=name --mtime='UTC 2020-01-01' \ |
| 55 | + --exclude=/proc --exclude=/sys --exclude=/dev \ |
| 56 | + --exclude=/mnt --exclude=/media --exclude=/run \ |
| 57 | + --exclude=/tmp/* --exclude=/var/tmp/* \ |
| 58 | + --exclude=/var/cache/pacman/pkg/* \ |
| 59 | + --exclude=/var/log/* \ |
| 60 | + / |
| 61 | + |
| 62 | +############################################### |
| 63 | +# EXPORT-ONLY: tarball artifact stage |
| 64 | +############################################### |
| 65 | +FROM scratch AS export |
| 66 | +COPY --from=builder /rootfs.tar /archlinuxarm-rpi-aarch64-rootfs.tar |
0 commit comments