Skip to content

Do not stage APKINDEX files into the apko_image cache - #412

Open
alexander-scott wants to merge 1 commit into
chainguard-dev:mainfrom
alexander-scott:patch-1
Open

alexander-scott wants to merge 1 commit into
chainguard-dev:mainfrom
alexander-scott:patch-1

Conversation

@alexander-scott

Copy link
Copy Markdown
Contributor

apk_repository fetches the live, unpinned APKINDEX.tar.gz for every repository in the lockfile, and is deliberately not marked reproducible because the bytes depend on when it ran. apko_image then copied those indexes into the cache tree artifact that the apko build action consumes, so the action keys for both the cache staging step and apko build were a function of fetch time. Two machines that fetched the index even minutes apart could never share a remote cache entry for the image, and Wolfi rewrites its index several times an hour.

apko build --lockfile never reads the index: it installs exactly the packages listed in the lockfile by URL and checksum (installablePackagesForArch -> InstallPackages) and only ResolveWorld, which is unreachable when a lockfile is given, loads repository indexes. Building with and without the indexes in the offline cache produces byte-identical OCI manifests on both amd64 and arm64.

Stop staging the indexes. The indexes output group of apk_filegroup is left in place for any other consumers; with nothing depending on it the apk_repository repos are no longer fetched for image builds either.

apk_repository fetches the live, unpinned APKINDEX.tar.gz for every
repository in the lockfile, and is deliberately not marked reproducible
because the bytes depend on when it ran. apko_image then copied those
indexes into the cache tree artifact that the apko build action consumes,
so the action keys for both the cache staging step and `apko build` were
a function of fetch time. Two machines that fetched the index even
minutes apart could never share a remote cache entry for the image, and
Wolfi rewrites its index several times an hour.

`apko build --lockfile` never reads the index: it installs exactly the
packages listed in the lockfile by URL and checksum
(installablePackagesForArch -> InstallPackages) and only ResolveWorld,
which is unreachable when a lockfile is given, loads repository indexes.
Building with and without the indexes in the offline cache produces
byte-identical OCI manifests on both amd64 and arm64.

Stop staging the indexes. The `indexes` output group of apk_filegroup is
left in place for any other consumers; with nothing depending on it the
apk_repository repos are no longer fetched for image builds either.

Signed-off-by: Alex Scott <alexanderscott@outlook.com>
@alexander-scott
alexander-scott marked this pull request as ready for review October 28, 2026 04:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant