fix(image): install the molecule image packages in one layer

One layer is about 30 MB compressed, far below the 100 MB proxy limit, and
saves three kaniko snapshots and three apt index downloads. Correct the size
estimate and the python3-systemd comment, note the build-time SSH host keys,
and drop the internal image name.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
This commit is contained in:
Defame1297andClaude Sonnet 5.5 committed 2026-10-24 21:10:20 +00:00
1 parent 0bc8d19775
commit c2465c7005
1 file changed
+17 -25
+17 -25
View File
@@ -1,7 +1,7 @@
# Molecule test target for the roles of this Collection: Ubuntu 24.04 with systemd
# as PID 1 and the packages the roles manage preinstalled, so a converge makes no
# network calls. It reproduces the homelab-molecule-ubuntu2404 image that the
# environment repo's gitea_runner role builds locally.
# network calls. It replaces the molecule test image that used to be built locally
# on the CI runner.
#
# Built by .gitea/workflows/image.yml with kaniko and pushed (never on pull
# requests) to git.rkdr.net/mortis/molecule-ubuntu2404. Consumers reference it
@@ -14,12 +14,16 @@
# scenario starts it with command /sbin/init, cgroupns_mode host, /sys/fs/cgroup
# mounted rw, tmpfs on /run and /run/lock, capability NET_ADMIN. No privileged mode.
#
# Layers are kept separate so each stays far below Cloudflare's 100 MB request-body
# limit on git.rkdr.net (kaniko pushes a layer as one request). Expected compressed
# sizes: base 29.8 MB (measured), the four RUN layers roughly 11 / 8 / 3 / 3 MB
# (estimated from the .deb download sizes). apt packages are not version-pinned,
# as in the original image; the base image is pinned by digest and a rebuild is a
# reviewed digest bump downstream.
# One RUN layer: about 30 MB compressed on top of the 29.8 MB base (estimated from
# the real .debs, with the .pyc files the postinst scripts compile), far below
# Cloudflare's 100 MB request-body limit on git.rkdr.net (kaniko pushes a layer as
# one request). apt packages are not version-pinned, as in the original image; the
# base image is pinned by digest and a rebuild is a reviewed digest bump downstream.
#
# The image carries SSH host keys and a machine-id generated at build time (the
# openssh-server and systemd postinst scripts). ssh.service runs `sshd -t` and
# fails without host keys, so they cannot be removed; image scanners will flag them.
# They are throwaway keys of a test target that is never exposed.
# ubuntu:24.04 index digest as of 2026-10-24 (24.04.5).
FROM ubuntu:24.04@sha256:68ee22004a9109b44973313b02ff7b1de250f1de0f5ecb628d73f579aaff33ac
@@ -30,28 +34,16 @@ LABEL org.opencontainers.image.title="molecule-ubuntu2404" \
ENV DEBIAN_FRONTEND=noninteractive
# Layer 1: systemd as PID 1, D-Bus, sudo, networking tools, CA certificates.
# systemd as PID 1 with D-Bus, sudo and networking tools; the Python Ansible needs on
# the target (python3-apt for the apt module); the firewall and intrusion-prevention
# packages the roles manage (python3-systemd is a dependency of fail2ban's systemd
# backend); sshd, enabled so a converge can test it under systemd.
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
systemd systemd-sysv dbus sudo iproute2 ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Layer 2: the Python Ansible needs on the target (python3-apt for the apt module,
# python3-systemd for the systemd module's journal access).
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
python3 python3-apt python3-systemd \
&& rm -rf /var/lib/apt/lists/*
# Layer 3: the firewall and intrusion-prevention packages the roles manage.
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
iptables ufw fail2ban \
&& rm -rf /var/lib/apt/lists/*
# Layer 4: sshd, enabled so a converge can test it under systemd.
RUN apt-get update \
&& apt-get install -y --no-install-recommends openssh-server \
openssh-server \
&& rm -rf /var/lib/apt/lists/* \
&& systemctl enable ssh