You are reading the docs for v0.0.1-beta-9. Latest (main) →

Runner image recipes

View .mdEdit on GitHub

Example runner images you can copy: a macOS image that boots iOS simulators and an Android emulator on demand, plus browser, mobile-release and Linux Android images.

← Back to README

An image is baked once by kinhin image prepare and cloned per job, so anything a recipe installs is on every runner from the first second of the job and costs nothing per run. The examples below are recipes, not defaults: change the versions, labels and names to yours.

What a recipe is#

Every recipe has three parts:

PartWhereWhat it does
Base imageimage: / base_image:The OS and what ships with it. A published Tart image, a local Tart VM, or a Debian/Ubuntu OCI image for the Linux runtimes.
Provision scriptprovision_script, or a pool'sRuns once inside the image after the runner agents install. Homebrew and mise are in the Tart base; apt-get in the Linux ones.
Labelslabels: on an images: entry, or a pool'sWhat runs-on: asks for. See Choosing the image per job.

Which key applies where:

RuntimeScript keyRuns asBudget
Tart (macOS and Linux VMs)top-level provision_scriptadmin30 minutes
apple/containercontainer.provision_script, or a pool'sroot30 minutes, shared with the rest of the build
Dockerdocker.provision_scriptroot30 minutes
  • The top-level script is shared by every Tart bake. One provision_script bakes into image:, every images: entry and every Linux Tart VM, so branch on the guest OS (uname -s) instead of keeping one script per image. The container and Docker keys are separate on purpose, so a macOS script cannot break a Linux bake.
  • …and on the image's role, not only its OS. There is one script per Mac, not one per Tart image, so a shared script has to decide each role's work from what its base carries: the mobile branch below runs only when xcodebuild -version answers, so the plain image: and the macos and web entries (no full Xcode) skip it instead of downloading a simulator runtime and an Android SDK. A base of your own that does have Xcode but must not get a toolchain cannot be told apart from inside the guest: give it a marker file in the base (/etc/kinhin-role, then test for it) or keep it in a second config.yaml on another Mac.
  • The script is your version pin. A Tart bake starts from the pristine base and replaces the image only when everything succeeded, so edit the script and re-prepare to change versions. Log the versions at the end (java -version, xcodebuild -version): the output is the audit trail in kinhin logs.
  • The script has a 30-minute budget. An iOS platform download is several gigabytes, and an Android system image one more, so keep each script to what its image needs. If it overruns, start from a base that already carries the toolchain instead of installing it.

macOS with iOS simulators and an Android emulator#

A named xcode image on a local Tart VM, plus the macOS branch of a shared provision script. The image itself stays warm; the simulator and the emulator boot per job, so nothing idles in a booted simulator.

# config.yaml
image: "ghcr.io/cirruslabs/macos-golden-gate-base:latest"   # the plain fleet image
provision_script: "~/kinhin/provision-mobile.sh"             # baked into every Tart image
images:
  - name: xcode
    base_image: "xcode-base"      # the local Tart VM you prepared
    labels: ["xcode"]             # runs-on: [self-hosted, macos, arm64, xcode]
    warm_pool: 1                  # keep one VM of this image booted for the next job

xcode-base is a VM you created and booted once yourself (Tart's documentation covers building one); kinhin only bakes its runner agents and your script into it. kinhin doctor flags a base_image that is neither a published image, a digest pin of one, nor a local VM, so a typo does not surface as a failed clone.

The script (one file, so it exits early on a Linux guest):

#!/bin/bash
# ~/kinhin/provision-mobile.sh — baked into every Tart image, so it branches on the guest
set -euo pipefail

if [[ "$(uname -s)" != "Darwin" ]]; then
  echo "not a macOS guest; nothing to install for the mobile image"
  exit 0
fi

# One script bakes into every Tart image, so the mobile role is selected by what the base carries: only an image with
# full Xcode (`xcode-base`, `macos-golden-gate-xcode`) gets the simulator runtime and the Android SDK. The plain
# `image:` and the `macos` and `web` entries skip this whole branch.
if ! xcodebuild -version >/dev/null 2>&1; then
  echo "no full Xcode in this base; the mobile toolchain belongs to the xcode/mobile images"
  exit 0
fi

# Full Xcode is in the base image; add the iOS platform and its simulator runtime.
xcodebuild -downloadPlatform iOS
runtime=$(xcrun simctl list runtimes | grep -o 'com\.apple\.CoreSimulator\.SimRuntime\.iOS-[0-9-]*' | tail -1)
for device in "iPhone 15" "iPhone 16"; do
  xcrun simctl list devices | grep -qF "${device} (" ||
    xcrun simctl create "$device" "com.apple.CoreSimulator.SimDeviceType.${device// /-}" "$runtime"
done

# Android: a JDK (sdkmanager is a Java program), then the command-line tools from
# Google, one platform, one arm64 system image and an AVD.
brew install openjdk@17
export JAVA_HOME="$(brew --prefix openjdk@17)/libexec/openjdk.jdk/Contents/Home"
export PATH="$JAVA_HOME/bin:$PATH"
export ANDROID_HOME="$HOME/android-sdk"
if [ ! -x "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" ]; then
  tmp=$(mktemp -d)
  curl -fsSL "https://dl.google.com/android/repository/commandlinetools-mac-11076708_latest.zip" -o "$tmp/tools.zip"
  unzip -q "$tmp/tools.zip" -d "$tmp"
  mkdir -p "$ANDROID_HOME/cmdline-tools"
  mv "$tmp/cmdline-tools" "$ANDROID_HOME/cmdline-tools/latest"
  rm -rf "$tmp"
fi
SDKMANAGER="$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager"
yes | "$SDKMANAGER" --sdk_root="$ANDROID_HOME" --licenses >/dev/null || true
"$SDKMANAGER" --sdk_root="$ANDROID_HOME" \
  "emulator" "platform-tools" "platforms;android-34" \
  "system-images;android-34;google_apis;arm64-v8a"
echo no | "$ANDROID_HOME/cmdline-tools/latest/bin/avdmanager" create avd -n kinhin-android \
  -k "system-images;android-34;google_apis;arm64-v8a" -g google --force

# The audit trail in `kinhin logs`: a missing piece fails the bake, not the first job.
java -version
"$SDKMANAGER" --sdk_root="$ANDROID_HOME" --list_installed
xcrun simctl list runtimes

Bake it, then watch a job use it:

kinhin image prepare --image xcode     # or --all, for image: and every images: entry
kinhin image list                      # the image, its size and whether a runner is using it
# .github/workflows/mobile.yml
on: workflow_dispatch

jobs:
  ios:
    runs-on: [self-hosted, macos, arm64, xcode]
    steps:
      - uses: actions/checkout@v4
      - run: xcodebuild -version && xcrun simctl list devices available

  android:
    runs-on: [self-hosted, macos, arm64, xcode]
    env:
      ANDROID_HOME: /Users/admin/android-sdk
      ANDROID_SDK_ROOT: /Users/admin/android-sdk
      JAVA_HOME: /opt/homebrew/opt/openjdk@17/libexec/openjdk.jdk/Contents/Home
    steps:
      - uses: actions/checkout@v4
      - name: Boot the emulator
        run: |
          "$ANDROID_HOME/emulator/emulator" -avd kinhin-android \
            -no-window -no-audio -no-snapshot-save &
          "$ANDROID_HOME/platform-tools/adb" wait-for-device
          until [ "$("$ANDROID_HOME/platform-tools/adb" shell getprop sys.boot_completed | tr -d '\r')" = 1 ]; do
            sleep 5
          done
      - run: ./gradlew connectedCheck

The variables go in the job's env: (as above) rather than in the image: macOS does not read /etc/profile.d, and a workflow step is not a login shell in any case. JAVA_HOME is the openjdk@17 the script installed, which Gradle needs. This repository's own mobile-capture job boots its emulator the same way (.github/workflows/video.yml), with Pixel_9 as the AVD name.

Caveats worth knowing before you copy it#

  • The emulator is software-rendered. Apple's Virtualization framework gives nested virtualization to Linux guests only, so a macOS guest has no Hypervisor.framework (sysctl -n kern.hv_support prints 0 inside the VM) and the emulator cannot use hardware acceleration. It still boots and runs a headless instrumented test, but in minutes, not seconds, and the VM wants its RAM (Hardware & sizing). Prefer a long job timeout and -no-window -no-audio. See Tart's FAQ for the framework limit.
  • A local VM base is never followed by image_updates. xcode-base has no registry, so image update never checks it: rebuild the local VM, then kinhin image prepare --image xcode. A registry base is different: pin it with kinhin image digest and let update: auto rebuild it (see Upgrading Xcode or macOS images).
  • One image is 40–60 GB, more with Xcode and an SDK. Decide that before you add a second one; kinhin image prune (or kinhin image delete NAME --yes) reclaims what nothing uses.
  • Label selection is GitHub-only. Other forges register runners with the fleet labels, so their jobs always run on image: (Runtimes).

More macOS images#

Each row is a separate images: entry with its own labels:, baked from the same shared provision_script — that is where its extra tools go, as further branches of it. Because one script serves every Tart image, each branch selects itself from what the base carries (the xcodebuild guard above is what keeps the mobile branch off the plain base); the rows that share a base and need different extras are the ones to split with a marker file, as described above.

Entrybase_imageWhat it addsTypical runs-on:
macosghcr.io/cirruslabs/macos-golden-gate-base:latestNothing but the runner agents and mise: Swift packages, swift build, native macOS apps[self-hosted, macos, arm64]
xcodexcode-base or ghcr.io/cirruslabs/macos-golden-gate-xcode:latestFull Xcode, iOS platform, simulators, Android SDK + AVD[self-hosted, macos, arm64, xcode]
appleghcr.io/cirruslabs/macos-golden-gate-xcode:latestEvery Apple platform runtime, for watchOS/tvOS/visionOS jobs[self-hosted, macos, arm64, apple]
webghcr.io/cirruslabs/macos-golden-gate-base:latestNode via mise, Playwright and Cypress browsers[self-hosted, macos, arm64, web]
mobilexcode-baseXcode, JDK, Android SDK, Ruby 3.2+ and fastlane for kinhin mobile init workflows[self-hosted, macos, arm64, mobile]

All-platforms runtimes, in the macOS branch of the script:

for platform in watchOS tvOS visionOS; do xcodebuild -downloadPlatform "$platform"; done

A web image, where the browsers are baked instead of downloaded per job:

# macOS branch
mise use --global node@22
corepack enable
npx --yes playwright@1.65.2 install chromium firefox webkit
npx --yes cypress install

Browsers belong to a Playwright version. Both browser recipes bake playwright@1.65.2, so the installed browser builds match that release. A job whose project pins another Playwright version does not find its browsers in the image and downloads them itself (or fails, if the download is blocked), so keep the image's pin in step with your projects — re-bake after a Playwright upgrade — or leave the browsers to the job.

A mobile-release image, matching what Mobile releases with fastlane needs on the runner:

# macOS branch
mise use --global ruby@3.3 fastlane@latest
gem install bundler
java -version && bundle --version && fastlane --version

Linux images#

Linux jobs run on apple/container or Docker, and those images install toolchains with kinhin-toolchain install per job unless a pool bakes them (Per-job toolchains). Bake when every job on the pool wants the same thing and the download is big. A base pinned with @sha256: never moves on its own, and a plain rebuild of a Linux image starts from the previous bake, so pin the base or use kinhin image update --apply when you want a newer one (Linux images).

ImageBaseBakesUse it for
kinhin-ci-linuxubuntu:24.04Nothing (the default)Most jobs; install toolchains per job
kinhin-ci-linux-androidubuntu:24.04JDK 17, Android SDK, NDK r26./gradlew assembleDebug, lint, unit tests
kinhin-ci-linux-browserubuntu:24.04Playwright's system dependencies and browsers (pinned playwright@1.65.2)Browser E2E without a per-job download, when the project uses that Playwright version
kinhin-ci-linux-dockerubuntu:24.04Agents plus docker: truedocker build, docker compose, testcontainers
kinhin-ci-linux-x64ubuntu:24.04, platform: linux/amd64Agents as x64x86_64-only toolchains, under Rosetta

The Android pool is the worked example: the script is examples/linux-android/provision-android.sh, and the pool needs an image of its own so its SDK bakes nowhere else:

container:
  pools:
    linux-large-android: # runs-on: [self-hosted, arm64, linux, kinhin-container-linux-large-android]
      platform: linux/amd64 # the NDK has no Linux arm64 host tools before r31
      cpus: 4
      memory_gb: 12
      image: kinhin-ci-linux-android
      provision_script: "~/kinhin/provision-android.sh"
kinhin image prepare --container --pool linux-large-android

A browser pool, baked once so no job downloads Chromium:

#!/bin/bash
# container.provision_script — runs as root in a Debian/Ubuntu image
apt-get update -qq
apt-get install -y -qq --no-install-recommends ca-certificates curl nodejs npm
npx --yes playwright@1.65.2 install --with-deps chromium firefox webkit

A Docker-in-Docker pool (testcontainers, docker compose up), which needs no script at all:

container:
  docker: true
  pools:
    linux-docker:
      image: kinhin-ci-linux-docker
      labels: [linux, docker]
      cpus: 4
      memory_gb: 12

An x64 pool: a separate image, because the platform is baked in.

container:
  pools:
    linux-x64:
      image: kinhin-ci-linux-x64
      labels: [linux]
      platform: linux/amd64
kinhin image prepare --container --pool linux-x64

An Android emulator is not a Linux image recipe. Neither runtime gives nested virtualization, so the emulator runs in software wherever it runs; this repository's own Android screenshot job runs it on the macOS image for that reason (Android SDK on Linux covers builds, not emulators).

Prepare, update and clean up#

kinhin image prepare                      # image: only
kinhin image prepare --image xcode        # one named images: entry
kinhin image prepare --all                # image: and every images: entry, one after another
kinhin image prepare --container --pool linux-large-android
kinhin image prepare --docker
kinhin image prepare --project owner/name # that repo's derived toolchain image, ahead of its first job
kinhin image digest ghcr.io/cirruslabs/macos-golden-gate-xcode:latest  # the @sha256: to pin
kinhin image update [--apply] [--image xcode]   # follow the registry
kinhin image rollback --image xcode             # rebuild from the digest it was baked from
kinhin image list                          # every image, its size, who is using it
kinhin image delete xcode                  # report only; add --yes to delete
kinhin image prune                         # stale records plus unused local images
kinhin doctor                              # disk headroom and image warnings

In the app, the macOS card's More images (under Advanced → Capacity) has one entry per named image with its base-image picker, status, Prepare, Rebuild… and Remove; a changed base_image only takes effect after a rebuild. A macOS bake runs in a scratch VM and swaps the image in at the end, so a failed or cancelled one leaves the previous image working (Cancelling a build).

Not verified#

These are example recipes, not a tested matrix. What this repository's own CI exercises is the headless Android emulator boot on a kinhin-xcode Tart runner for store screenshots (.github/workflows/video.yml, recorded in Store screenshots); the Apple-platform downloads, the browser and mobile-release macOS images and the Linux browser and x64 pools were not run as part of writing this page. Check one job on each new image before you route a whole workflow to it.