How Alpine apk caching works
Each Alpine repository has an APKINDEX.tar.gz, signed by the Alpine developers, that lists packages and their checksums. apk verifies the index signature and every package checksum, so a cache in the middle cannot change what gets installed.
Alpine images include CA certificates, so the HTTPS endpoint works from the first line of a Dockerfile.
- APKINDEX
- Refreshed every 15 minutes per branch and architecture.
- .apk packages
- Cached forever.
- Edge and testing
- Supported, with the same refresh rules.
Set it up
Dockerfile
FROM alpine:3.20
RUN sed -i "s|https://dl-cdn.alpinelinux.org|https://acme.cacheport.cc/apk|g" /etc/apk/repositories \
&& apk add --no-cache git curlThis form relies on an IP allowlist for your runners. To use a token, pass it as a build secret and put it in the repository URL as https://ci:TOKEN@acme.cacheport.cc/apk inside the same RUN step, so it never lands in an image layer.
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
container: alpine:3.20
steps:
- run: sed -i "s|https://dl-cdn.alpinelinux.org|https://acme.cacheport.cc/apk|g" /etc/apk/repositories
- run: apk add --no-cache make gcc musl-dev
- uses: actions/checkout@v4
- run: make testMore for GitHub Actions: GitHub Actions setup guide.
GitLab CI
test:
image: alpine:3.20
before_script:
- sed -i "s|https://dl-cdn.alpinelinux.org|https://acme.cacheport.cc/apk|g" /etc/apk/repositories
- apk add --no-cache make gcc musl-dev
script:
- make testMore for GitLab CI: GitLab CI setup guide.
Base images from the cache too
The alpine image itself comes from Docker Hub. Pull it through the Docker Hub cache as acme.cacheport.cc/hub/library/alpine:3.20 and the whole build stays inside Cacheport.