How apt caching works
apt verifies repository metadata with the distribution's signing keys and every package against hashes in that metadata. That is why apt mirrors traditionally use plain HTTP: the transport does not need to be trusted. Cacheport accepts both HTTP and HTTPS for apt.
Slim base images ship without CA certificates, so HTTPS sources fail until ca-certificates is installed. For image builds, use the HTTP endpoint with an IP allowlist for your runners; switch to HTTPS with a token once certificates are present.
- Release and InRelease
- Refreshed every 15 minutes, signatures checked by apt.
- Packages indexes
- Refreshed with the release files they belong to.
- .deb files
- Cached forever, identical to the mirror.
Set it up
Debian 12 and later (deb822 sources)
FROM debian:bookworm-slim
RUN sed -i "s|http://deb.debian.org|http://acme.cacheport.cc/apt/deb.debian.org|g" /etc/apt/sources.list.d/debian.sources \
&& apt-get update \
&& apt-get install -y --no-install-recommends curl ca-certificates \
&& rm -rf /var/lib/apt/lists/*Ubuntu 24.04
FROM ubuntu:24.04
RUN sed -i "s|http://archive.ubuntu.com|http://acme.cacheport.cc/apt/archive.ubuntu.com|g" /etc/apt/sources.list.d/ubuntu.sources \
&& apt-get update \
&& apt-get install -y --no-install-recommends build-essential \
&& rm -rf /var/lib/apt/lists/*The HTTP endpoint only answers requests from the IP ranges you allow in the workspace. With a token, use HTTPS and put the credentials in /etc/apt/auth.conf.d/ through a build secret.
Use it in CI
Store the token as a secret named CACHEPORT_TOKEN, then pick your provider.
GitHub Actions
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Use Cacheport for apt
run: |
sudo sed -i "s|http://azure.archive.ubuntu.com|https://acme.cacheport.cc/apt/archive.ubuntu.com|g" /etc/apt/sources.list.d/ubuntu.sources
printf "machine acme.cacheport.cc login ci password %s\n" "${{ secrets.CACHEPORT_TOKEN }}" | sudo tee /etc/apt/auth.conf.d/cacheport.conf > /dev/null
sudo apt-get update
- run: sudo apt-get install -y libpq-devMore for GitHub Actions: GitHub Actions setup guide.
GitLab CI
test:
image: debian:bookworm-slim
before_script:
- sed -i "s|http://deb.debian.org|http://acme.cacheport.cc/apt/deb.debian.org|g" /etc/apt/sources.list.d/debian.sources
- apt-get update && apt-get install -y --no-install-recommends make gcc
script:
- make testMore for GitLab CI: GitLab CI setup guide.
Security updates
Rewrite the security repository too, for example security.debian.org, so security updates come through the cache. Release files for security repositories refresh on the same 15-minute schedule, so updates appear quickly.
Troubleshooting
Errors that usually mean the public registry is the bottleneck, and what Cacheport changes about them.