Skip to content

Instantly share code, notes, and snippets.

@Ronmi
Created January 13, 2025 09:20
Show Gist options
  • Save Ronmi/5241be6c6e2b9457a91c2a60958a160c to your computer and use it in GitHub Desktop.
Save Ronmi/5241be6c6e2b9457a91c2a60958a160c to your computer and use it in GitHub Desktop.
Enable local cache for Forgejo action runner

By default, cache location when running CI tasks is /opt/hostedtoolcache. It's okay to change it by setting 3 envvars in config.yaml

runner:
  envs:
    RUNNER_TOOL_CACHE: /path/to/cache
    AGENT_TOOLSDIRECTORY: /path/to/cache
    RUN_TOOL_CACHE: /path/to/cache

Haven't tried but I think you should use same dir for these envvars.

In the following docs, we'll use

  • /opt/hostedtoolcache for cache dir CI action use
  • /home/user/cache for cache dir on host machine

And all we gonna do is mapping /home/user/cache to /opt/hostedtoolcache

Stop runner

You should stop runner first as we're gonna edit config.yaml

Editing config.yaml

Add following to config.yaml

container:
  options: "-v /home/user/cache:/opt/hostedtoolcache"
  valid_volumes:
    - /opt/hostedtoolcache

Extra step if use DIND (docker in docker)

mount /home/user/cache into dind container by

  • If you use docker run, add -v /home/user/cache:/home/user/cache
  • If you use docker compose, add - /home/user/cache:/home/user/cache to volume setting in docker-compose.yml

Done

Restart runner (and dind container if you're using it)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment