posit-dev / posit-dev/images-shared
Add ECR support to Bakery registry cleanup tooling
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2
- Forks
- 0
- Avg merge
- 4d 13h
- Merged PRs (30d)
- 22
Description
Background
Amazon ECR Public has no native lifecycle-policy feature (confirmed via aws ecr-public help — no put-lifecycle-policy/get-lifecycle-policy, unlike private ecr; also absent
from AWS docs). The only deletion mechanism is batch-delete-image by tag or digest. Cleanup
has to be enforced client-side, the same way Bakery already handles this for GHCR
(posit_bakery/registry_management/ghcr/) and Docker Hub
(posit_bakery/registry_management/dockerhub/).
bakery clean cache-registry and bakery clean temp-registry currently document themselves
as GHCR-only:
⚠️ This command currently only supports GHCR registries. ⚠️
This issue adds ECR as a supported registry for that cleanup tooling, so any image publishing
to ECR can prune old/untagged images the same way GHCR- and Docker Hub-published images do.
Scope
- Add
posit_bakery/registry_management/ecr/withapi.py(client wrapping the
ecr-publicdescribe-images/batch-delete-imageAPI, following theGHCRClient/
DockerhubClientshape),models.py(equivalent toGHCRPackageVersions, with
older_than()/untagged()filtering), andclean.py(clean_registry()/
clean_temporary_artifacts(), matching the GHCR/Docker Hub signatures). - Match the existing registry-pattern convention used by GHCR (
ghcr\.io/...) and Docker
Hub (docker\.io/...) — add an ECR pattern (public\.ecr\.aws/..., and decide whether
private ECR URIs need to be supported too). - Wire ECR into
bakery clean cache-registryandbakery clean temp-registry(remove the
GHCR-only restriction, update command docstrings/help text). - Reuse the existing default retention windows already used by
clean_registry()for
GHCR/Docker Hub (remove_tagged_older_than=80 weeks,remove_untagged_older_than=26 weeks) as the ECR defaults, overridable via the same CLI flags (--older-than,
--untagged, etc.) already exposed for the other registries. - Unit tests mirroring
test/registry_management/ghcr/andtest/registry_management/ dockerhub/, plus CLI tests mirroringtest/cli/test_clean.py. - Confirm AWS auth/credentials handling needed for
ecr-publicAPI calls in CI (OIDC role
permissions, region requirement —ecr-publicAPI isus-east-1only regardless of
repository region).
Out of scope
- Determining what retention values any specific image should use — a per-image/consumer
decision, tracked separately. - Provisioning any ECR repository.
Related
- posit-dev/platform-team#457
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing posit_bakery/registry_management/ghcr/ and dockerhub/, then inspect the cleanup command implementation and test/cli/test_clean.py. Add the ECR client, models, cleanup paths, registry matching, and mirrored unit tests described in the issue. Done means both cleanup commands support ECR with the existing retention flags and CI authentication requirements are confirmed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, python
- Domain
- cloud, devops, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100