cacheport

Ecosystem · System

apt package cache for Debian and Ubuntu builds

apt-get update and apt-get install run in almost every Dockerfile. Rewrite the mirror URL once and packages come from Cacheport, with apt still checking every signature against the distribution keys.

CP-APTManifest
Upstream
deb.debian.org, security.debian.org, archive.ubuntu.com
Endpoint
http(s)://acme.cacheport.cc/apt/<mirror host>/
Config
sources in /etc/apt
Access
Token or IP allowlist
Release files
Refreshed every 15 minutes
.deb files
Cached forever, signatures verified by apt

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.

What gets cached
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)

Dockerfile
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

Dockerfile
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

.github/workflows/ci.yml
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-dev

More for GitHub Actions: GitHub Actions setup guide.

GitLab CI

.gitlab-ci.yml
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 test

More 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.

Questions

Is plain HTTP safe here?

For apt, yes: apt verifies signatures and hashes regardless of transport. The HTTP endpoint only serves IP ranges you allow.

Does it work with PPAs and third-party repositories?

Yes. Add the repository host as an upstream and rewrite its URL the same way.

Do GitHub-hosted runners use a different mirror?

They use an Azure mirror of archive.ubuntu.com. The example replaces that host.

Other ecosystems people set up next

Start on the free plan

20 GB of cache, every registry, unlimited users. Upgrade when your pipelines outgrow it.