fix(ci): build the ISO in a privileged container via the host Docker socket

This commit is contained in:
BlackAngelTV committed 2026-12-04 15:33:56 +01:00
1 parent c704a72d3e
commit c233440b77
2 files changed
+80 -27

No files matched your search

+24 -25
View File
@@ -38,8 +38,9 @@ concurrency:
jobs:
release:
# Organisation runners: labels arch-host, ubuntu-latest, debian, alpine.
# mkarchiso needs an Arch environment, root, loop devices and mount, so the
# job must run privileged (act_runner: container.privileged = true).
# Jobs run in an unprivileged Arch container (mount denied, no user
# namespaces), so build-offi.sh builds in a privileged archlinux container
# through the host's Docker socket.
runs-on: arch-host
timeout-minutes: 180
@@ -69,39 +70,37 @@ jobs:
./release.sh --check
fi
- name: Outils du runner (docker)
if: steps.check.outputs.publish == 'true' || inputs.build_only
run: |
# The job runs in an unprivileged container: mount() is denied and
# user namespaces are off. build-offi.sh detects that and runs
# mkarchiso in a privileged archlinux container through the host
# Docker socket, so only the Docker CLI is needed here.
SUDO=(); [ "$(id -u)" -eq 0 ] || SUDO=(sudo)
"${SUDO[@]}" pacman -S --needed --noconfirm --quiet docker
- name: Pré-vol du runner
if: steps.check.outputs.publish == 'true' || inputs.build_only
run: |
for c in bash curl jq git pacman; do
for c in bash curl jq git pacman docker; do
command -v "${c}" >/dev/null 2>&1 \
|| { echo "::error::${c} absent du runner"; exit 1; }
done
# mkarchiso needs root: either the job already runs as root, or the
# runner allows passwordless sudo.
# build-offi.sh elevates itself once, to install packages and drive
# Docker; the build itself runs as root in the privileged container.
[ "$(id -u)" -eq 0 ] || sudo -n true 2>/dev/null \
|| { echo "::error::mkarchiso exige root (job root ou sudo sans mot de passe)"; exit 1; }
|| { echo "::error::sudo sans mot de passe requis (installation des paquets) "; exit 1; }
# mkarchiso bind-mounts /proc and /dev inside the chroot and loops the
# squashfs. In a non-privileged container mount() is denied even as
# root, and the build only dies at pacstrap minutes later: check now.
SUDO=(); [ "$(id -u)" -eq 0 ] || SUDO=(sudo)
MP="$(mktemp -d)"
if ! MOUNT_ERR="$("${SUDO[@]}" mount -t tmpfs tmpfs "${MP}" 2>&1)"; then
rmdir "${MP}" 2>/dev/null || true
echo "::error::le runner refuse mount() : ${MOUNT_ERR}"
echo "::error::mkarchiso a besoin de CAP_SYS_ADMIN + des loop devices. Config act_runner : container.privileged: true puis redémarrer le daemon, ou enregistrer le label arch-host en mode host."
# The privileged container is the only place where mount() works:
# prove the socket and a mount now, not after 20 minutes of build.
[ -S /var/run/docker.sock ] \
|| { echo "::error::/var/run/docker.sock absent : impossible de lancer le conteneur de build"; exit 1; }
if ! MOUNT_ERR="$(docker run --rm --privileged archlinux:latest \
sh -c 'mount -t tmpfs tmpfs /mnt && umount /mnt' 2>&1)"; then
echo "::error::le conteneur de build ne peut pas monter : ${MOUNT_ERR}"
exit 1
fi
"${SUDO[@]}" umount "${MP}" && rmdir "${MP}"
- name: Dépendances de l'hôte (mkarchiso)
if: steps.check.outputs.publish == 'true' || inputs.build_only
run: |
# mkarchiso validates the host tools of every boot mode of the
# profile and aborts otherwise: grub-install (uefi.grub), mkfs.fat
# (dosfstools) and mcopy (mtools). --needed: no-op once present.
SUDO=(); [ "$(id -u)" -eq 0 ] || SUDO=(sudo)
"${SUDO[@]}" pacman -S --needed --noconfirm --quiet grub dosfstools mtools
- name: Build officiel et publication
if: steps.check.outputs.publish == 'true' || inputs.build_only