Skip to content

ci: add a workflow to cleanup unused manifests - #12362

Merged
peaklabs-dev merged 8 commits into
mainfrom
ci/clean-unused-images
Oct 30, 2026
Merged

peaklabs-dev merged 8 commits into
mainfrom
ci/clean-unused-images

Conversation

@peaklabs-dev

@peaklabs-dev peaklabs-dev commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Add a script that deletes the unused manifests of the Coolify image on ghcr.io and docker.io, and a workflow that only lists them for now.

Changes

  • Add scripts/clean-manifests.sh, which lists the unused manifests and deletes as many as --delete <count> asks for
    • Keep latest, preview, main, nightly, every version tag, every git tag, the pr-* tags of open pull requests, the nightlies of the last 14 days, v3 and the 4.0.0-beta.420.x versions, and every index, image and attestation they point at
    • Keep every manifest younger than a day, because a build pushes its images before the index that tags them
    • Delete from ghcr.io first, then from docker.io. The next two runs retry a manifest that docker.io refused after ghcr.io deleted it
    • Fail the run when a kept tag or a manifest it points at is gone afterwards
    • Pass the Docker Hub login to curl on stdin, and check each version id and digest before a delete
  • Add a manual workflow that runs the script as a dry run, without --delete, and uploads the list of manifests to delete as an artifact for 90 days
  • Read the delete tokens from the cleanup environment, which only main can use and which will later need a maintainer's approval before a run can read them

Why

ghcr.io and docker.io hold 36,660 manifests that no kept tag needs: 13,716 indexes, 18,362 images and 4,582 attestations. They are the per-platform indexes of the old release workflows, next, sha-* and branch builds, old nightlies and the images of closed pull requests. Deleting them frees 1.6 TB on ghcr.io, from 1.8 TB down to 138.8 GB.

The dry run lists all of them for review.

@peaklabs-dev
peaklabs-dev changed the base branch from next to main October 30, 2026 18:37
- v3 and 4.0.0-beta.420.x do not follow semantic versioning, KEEP_TAG_EXCEPTIONS keeps them explicitly
- with a run every hour and 200 deletions per run the about 35,000 unused manifests on ghcr.io and docker.io are deleted in about 7 days, then the schedule goes back to every 2 weeks or every month
- a run deletes 200 at most, as GitHub allows an account 500 requests per hour and the ghrc.io PAT is an account level PAT
- docker_hub is undefined for a manifest ghcr.io has, as a HEAD on docker.io for every one of them could trigger rate limits
- ghcr.io lists deleted versions for 30 days, a HEAD on docker.io for each would reach thousands per run, which could trigger rate limits
- twice the delete limit covers the last two runs, and manifests only docker.io has sort first, so a copy docker.io refused is deleted within two runs
- a manually triggered first run in CI uploads the full list of manifests to delete
- a later pull request makes the workflow hourly again
- a build pushes its images before the index that tags them, a run in between would see them as unused
- a push while the run reads the pages of versions shows one version twice, the list keeps it once so the second delete does not stop the run
- passes the Docker Hub login to curl on stdin, which keeps it out of the process list
- checks the format of version ids and digests before a delete
@peaklabs-dev
peaklabs-dev force-pushed the ci/clean-unused-images branch from dc1dcbb to fb0210f Compare October 30, 2026 22:03
@peaklabs-dev peaklabs-dev changed the title ci(image): delete unused images every hour ci: add a workflow to cleanup unused manifests Oct 30, 2026
@peaklabs-dev
peaklabs-dev marked this pull request as ready for review October 30, 2026 22:19
@peaklabs-dev
peaklabs-dev merged commit 751ecb9 into main Oct 30, 2026
1 check passed
@peaklabs-dev
peaklabs-dev deleted the ci/clean-unused-images branch October 30, 2026 22:19
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