CI: pre-bake Flutter toolchain and Android SDK into the runner Dockerfile to speed cold-cache starts #496

Closed
opened 2026-06-06 15:43:18 +00:00 by guettlibot · 1 comment
guettlibot commented 2026-06-06 15:43:18 +00:00 (Migrated from codeberg.org)

Problem

The toolchain() function in ci/main.go does all heavy SDK setup inside Dagger containers:

  • apt-get install with ~15 packages: ~1–2 min
  • sdkmanager downloading NDK 28 + cmake + build-tools: ~5–15 min (network-dependent)
  • flutter precache: ~2–5 min

This is execution-cached by Dagger on the remote engine. On a cold cache (after dagger prune, engine migration, or initial setup), it adds 10–20 min before any actual compilation begins.

Fix

Move the Flutter image, apt installs, and Android SDK downloads into the Forgejo runner Dockerfile (.forgejo/Dockerfile). Then toolchain() in ci/main.go references this pre-baked image instead — those steps become cheap Docker layer hits.

The Flutter version in the Dockerfile must stay in sync with .fvmrc.

Expected impact

  • Cold-cache start time drops from ~15–20 min to ~1–2 min.
  • Warm-cache (normal) runs are unaffected.
  • Protects against the Dagger remote engine cache being pruned by disk pressure.

Files to change

  • .forgejo/Dockerfile — add Flutter/Android SDK layers
  • ci/main.go — toolchain() — change From() to use the pre-baked image
  • scripts/check_ci_images.sh — update image reference
## Problem The toolchain() function in ci/main.go does all heavy SDK setup inside Dagger containers: - apt-get install with ~15 packages: ~1–2 min - sdkmanager downloading NDK 28 + cmake + build-tools: ~5–15 min (network-dependent) - flutter precache: ~2–5 min This is execution-cached by Dagger on the remote engine. On a cold cache (after dagger prune, engine migration, or initial setup), it adds 10–20 min before any actual compilation begins. ## Fix Move the Flutter image, apt installs, and Android SDK downloads into the Forgejo runner Dockerfile (.forgejo/Dockerfile). Then toolchain() in ci/main.go references this pre-baked image instead — those steps become cheap Docker layer hits. The Flutter version in the Dockerfile must stay in sync with .fvmrc. ## Expected impact - Cold-cache start time drops from ~15–20 min to ~1–2 min. - Warm-cache (normal) runs are unaffected. - Protects against the Dagger remote engine cache being pruned by disk pressure. ## Files to change - .forgejo/Dockerfile — add Flutter/Android SDK layers - ci/main.go — toolchain() — change From() to use the pre-baked image - scripts/check_ci_images.sh — update image reference
guettli commented 2026-06-06 23:24:50 +00:00 (Migrated from codeberg.org)

not planned

not planned
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: guettli/sharedinbox#496