Skip to content
Latchkey

How to Bake Dependencies Into a Self-Hosted Runner Image in GitHub Actions

Baking compilers, SDKs, and system packages into the runner image removes repeated install time from every job.

Build a golden image (an AMI with Packer, or a container image) that already has your toolchain. Jobs then start with everything installed instead of running apt or brew on every run.

Steps

  • List the tools every job installs at runtime today.
  • Add them to a Packer template or Dockerfile.
  • Build a versioned image and roll it out to the runner fleet.
  • Drop the per-job install steps from your workflows.

Dockerfile layer

Dockerfile
FROM ghcr.io/actions/actions-runner:latest
USER root
RUN apt-get update && apt-get install -y --no-install-recommends \
      build-essential cmake jq awscli \
  && rm -rf /var/lib/apt/lists/*
USER runner

Gotchas

  • Pin tool versions in the image so builds stay reproducible.
  • Rebuild and re-roll the image on a schedule to pick up security updates.
  • GitHub publishes the actions/runner-images definitions you can mirror as a starting point.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →