Skip to content

feat(rpi-image): trim image by skipping stage2 + minimal Docker install - #193

Closed
frahlg wants to merge 1 commit into
183-rpi-sd-imagefrom
pi-gen-trim
Closed

frahlg wants to merge 1 commit into
183-rpi-sd-imagefrom
pi-gen-trim

Conversation

@frahlg

@frahlg frahlg commented Apr 25, 2026

Copy link
Copy Markdown
Member

Why

Stock pi-gen output for our use case carries ~1 GB of rootfs the dashboard never touches. We boot, run docker-compose, serve a web UI — none of stage2's "comfort" CLI tooling (`vim`, `less`, `raspi-config`, `build-essential`, `python3-pip`, `network-manager-gnome`, `fonts-*`, `htop`) is on the critical path. The Docker convenience script also pulls `docker-ce-rootless-extras`, `docker-buildx-plugin`, and `docker-model-plugin` (~300 MB combined) that we have no use for.

Stacked on #186. Merge target: `183-rpi-sd-image` (so the trim sits on top of the three earlier image-pipeline fixes).

What

Three coordinated changes:

  1. Drop stage2 from STAGE_LIST. pi-gen now runs only `stage0 + stage1 + stage-42w`. SKIP + SKIP_IMAGES files dropped on stage2-5 in `build.sh`.

  2. Pull the stage2 packages we actually need into stage-42w. Added to `00-install-packages/00-packages`:

    • `network-manager` — wifi-connect depends on it; we already mask dhcpcd in 02-wifi-onboarding.
    • `raspberrypi-sys-mods` — provides `/usr/lib/raspberrypi-sys-mods/firstboot` which handles partition-resize + ssh-enable on first boot, the same job stage2/01-sys-tweaks did.
  3. Replace `curl get.docker.com | sh` with explicit Docker apt repo + minimal package list: `docker-ce`, `docker-ce-cli`, `containerd.io`, `docker-compose-plugin`. Same Docker apt URL the convenience script uses, just without the bloat we don't run.

`01-ftw-setup/00-run.sh` also explicitly enables `NetworkManager.service` + injects `init=/usr/lib/raspberrypi-sys-mods/firstboot` into `cmdline.txt` so the first-boot resize still happens — both jobs stage2 used to do.

Expected impact

Image: 3.0 GB → ~2.0 GB uncompressed, 561 MB → ~350 MB compressed.

Test plan

🤖 Generated with Claude Code

The stock pi-gen output for our use case is fat with stuff we don't
need: stage2's "comfort" CLI tooling (vim, less, raspi-config,
build-essential, python3-pip, network-manager-gnome, fonts-*, htop)
adds ~700 MB of rootfs the dashboard never touches. The Docker
convenience script pulls in another ~300 MB of rootless-extras,
buildx, and model-plugin we have no use for.

Three coordinated changes:

1. Drop stage2 from STAGE_LIST. pi-gen now runs stage0 + stage1 +
   stage-42w only. SKIP + SKIP_IMAGES files dropped on stage2-5
   in build.sh so pi-gen doesn't touch them.

2. Pull the stage2 packages we actually need into stage-42w's own
   00-packages list — `network-manager` (wifi-connect depends on
   it; we already disable dhcpcd in 02-wifi-onboarding) and
   `raspberrypi-sys-mods` (provides /usr/lib/raspberrypi-sys-mods/
   firstboot which does partition-resize + ssh-enable on first
   boot — same job stage2/01-sys-tweaks would have done).

3. Replace `curl get.docker.com | sh` with explicit Docker apt
   repo + `apt-get install --no-install-recommends docker-ce
   docker-ce-cli containerd.io docker-compose-plugin`. We're not
   running rootless, not building images on the Pi, and have no
   AI workloads — the four packages above are what
   `docker compose up -d` against a pulled image actually needs.

01-ftw-setup also explicitly enables NetworkManager.service +
injects `init=/usr/lib/raspberrypi-sys-mods/firstboot` into
cmdline.txt so the first-boot resize still happens — both jobs
stage2 used to do.

Expected impact: image ~3.0 GB → ~2.0 GB uncompressed, ~561 MB →
~350 MB compressed. CI on this PR is the validation.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant