Skip to content

Instantly share code, notes, and snippets.

@FlorianHeigl
Created May 7, 2026 20:12
Show Gist options
  • Select an option

  • Save FlorianHeigl/535f0db4decfe7ed6610baa85f8c910e to your computer and use it in GitHub Desktop.

Select an option

Save FlorianHeigl/535f0db4decfe7ed6610baa85f8c910e to your computer and use it in GitHub Desktop.
gitlab-ci-local apt caching, ccache caching
---
stages:
- bootstrap
default:
image: ubuntu:22.04
tags:
- docker
variables:
# FORCE_UNSAFE_CONFIGURE: 1
HTTP_PROXY: http://proxy:3128
HTTPS_PROXY: http://proxy:3128
FTP_PROXY: http://proxy:3128
http_proxy: http://proxy:3128
https_proxy: http://proxy:3128
ftp_proxy: http://proxy:3128
bootstrap:
stage: bootstrap
cache:
paths:
- ccache
- .apt
before_script:
# gitlab docs use a bind mount, that is NOT NEEDED, you can just use symlinks like shown here
- rm -f /etc/apt/apt.conf.d/docker-clean
- mkdir -p .apt/cache .apt/cache/partial .apt/lists || true
- rm -r /var/cache/apt/archives /var/lib/apt/lists || true
- ln -sfn ${CI_PROJECT_DIR}/.apt/cache /var/cache/apt/archives
- ln -sfn ${CI_PROJECT_DIR}/.apt/lists /var/lib/apt/lists
- apt update
- DEBIAN_FRONTEND=noninteractive apt-get -yq dist-upgrade
- DEBIAN_FRONTEND=noninteractive apt-get -yq install ccache
- DEBIAN_FRONTEND=noninteractive apt-get -yq install pkg-config build-essential ninja-build automake autoconf libtool wget curl git gcc libssl-dev bc slib squashfs-tools android-sdk-libsparse-utils jq python3-distutils scons parallel tree python3-dev python3-pip device-tree-compiler ssh cpio fakeroot libncurses5 flex bison libncurses5-dev genext2fs rsync unzip dosfstools mtools tcl openssh-client cmake expect python-is-python3 python3-jinja2
# copied from somewhere
- export PATH="/usr/lib/ccache:$PATH" # Override compiler path with ccache (this example is for Debian)
- export CCACHE_DIR="${CI_PROJECT_DIR}/ccache"
- export CCACHE_BASEDIR="${CI_PROJECT_DIR}"
- export CCACHE_COMPILERCHECK=content # Compiler
script:
- ccache --zero-stats || true
- run and build stuff
- done with stuff
image:
name: ubuntu:22.04
tags:
- docker
@FlorianHeigl
Copy link
Copy Markdown
Author

oh well and what do you know, uploading the cache at the end is also taking considerable time so it would appear there's no gain even though the install phase was so much faster.

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