CI: cache Android SDK/NDK, Gradle, and npm across APK builds
Persist three Docker volumes into the build job (android-sdk, gradle home, npm cache) and enable the Gradle build cache, so repeat builds skip the ~2GB NDK download, Maven dependency resolution, and unchanged native/Kotlin compilation — cutting builds from ~1h to a few minutes after the first run. The runner must whitelist these volumes via config.yaml (container.valid_volumes); deploy-runner.sh now writes that config, pre-creates the volumes, and starts the daemon with --config. Requires re-running deploy-runner.sh on the runner host before the next tag. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
1ca2c38fbf
commit
3583c2e15f
5 changed files with 89 additions and 12 deletions
|
|
@ -30,6 +30,27 @@ The runner advertises the `docker` label; the build workflow (`.forgejo/workflow
|
|||
2. Push a tag: `git tag v0.1.0 && git push origin v0.1.0`.
|
||||
3. The runner builds `camp-scan-v0.1.0.apk` and attaches it to a Forgejo release; Obtainium picks it up.
|
||||
|
||||
## Build caching (fast repeat builds)
|
||||
|
||||
The first APK build takes ~1h (downloads Gradle + the ~2GB Android NDK, resolves
|
||||
all Maven deps, compiles native modules). After that it should drop to a few
|
||||
minutes because three persistent Docker volumes are reused across runs:
|
||||
|
||||
| Volume | Holds |
|
||||
|---|---|
|
||||
| `camptickets-android-sdk` → `/opt/android-sdk` | SDK, NDK, CMake |
|
||||
| `camptickets-gradle` → `/root/.gradle` | Gradle dist, Maven deps, local build cache |
|
||||
| `camptickets-npm` → `/root/.npm` | npm download cache |
|
||||
|
||||
For this to work the runner must **allow** these volumes via `config.yaml`
|
||||
(`container.valid_volumes`) — `deploy-runner.sh` writes that config, pre-creates
|
||||
the volumes, and starts the daemon with `--config /data/config.yaml`. If you set
|
||||
the runner up by hand, copy `config.yaml` next to the compose file and add
|
||||
`--config /data/config.yaml` to the daemon command.
|
||||
|
||||
To force a clean rebuild, remove the volumes:
|
||||
`docker volume rm camptickets-android-sdk camptickets-gradle camptickets-npm`.
|
||||
|
||||
## Notes
|
||||
|
||||
- The runner I initially registered on the app host has been removed. If Forgejo
|
||||
|
|
@ -37,3 +58,6 @@ The runner advertises the `docker` label; the build workflow (`.forgejo/workflow
|
|||
*Settings → Actions → Runners*.
|
||||
- `DOCKER_GID` must match the roomy server's docker socket group, or the runner
|
||||
can't reach the Docker daemon.
|
||||
- After updating to a caching-enabled runner, re-run `deploy-runner.sh` (or
|
||||
`docker compose up -d` in the runner dir) so the new `config.yaml` + volumes
|
||||
take effect, then push a fresh tag.
|
||||
|
|
|
|||
9
runner/config.yaml
Normal file
9
runner/config.yaml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# Forgejo runner config. The important bit is valid_volumes: it whitelists the
|
||||
# named Docker volumes the build-apk workflow mounts as persistent caches
|
||||
# (Android SDK/NDK, Gradle home, npm cache). Without these listed, the runner
|
||||
# rejects the workflow's `volumes:` and the job fails.
|
||||
container:
|
||||
valid_volumes:
|
||||
- camptickets-android-sdk
|
||||
- camptickets-gradle
|
||||
- camptickets-npm
|
||||
|
|
@ -11,6 +11,9 @@ services:
|
|||
- "${DOCKER_GID:-988}"
|
||||
volumes:
|
||||
- ./data:/data
|
||||
# config.yaml allows the build workflow to mount the persistent cache
|
||||
# volumes (valid_volumes); without it those mounts are rejected.
|
||||
- ./config.yaml:/data/config.yaml:ro
|
||||
# Runner spawns job containers via the host Docker daemon.
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
env_file: .env
|
||||
|
|
@ -31,4 +34,4 @@ services:
|
|||
--name "${RUNNER_NAME:-camptickets-runner}" \
|
||||
--labels "docker:docker://node:22-bookworm"
|
||||
fi
|
||||
exec forgejo-runner daemon
|
||||
exec forgejo-runner daemon --config /data/config.yaml
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue