Skip to content

Add ECR Public mirroring for slim images via dispatch - #286

Open
avallete wants to merge 1 commit into
mainfrom
claude/mirror-slim-images-github-nvvrhy
Open

Add ECR Public mirroring for slim images via dispatch#286
avallete wants to merge 1 commit into
mainfrom
claude/mirror-slim-images-github-nvvrhy

Conversation

@avallete

Copy link
Copy Markdown
Member

Summary

This change adds automated mirroring of slim images from GHCR to AWS ECR Public by leveraging the existing mirror infrastructure in the supabase/cli repository. Images are mirrored via a repository_dispatch event, with verification that the destination digest matches the source before releasing.

Key Changes

  • New scripts/ecr-mirror.sh: Main script providing four subcommands:

    • payload: Renders a repository_dispatch request body for a single release
    • request: Sends the dispatch event and polls the destination until the digest matches
    • verify: Polls the destination until the digest matches (no-op if already synced)
    • sync: Compares all published releases against ECR Public and reports drift; with --request flag, dispatches mirror requests for missing/mismatched tags
  • New scripts/test-ecr-mirror.sh: Comprehensive test suite validating:

    • Payload rendering with correct event type and client payload structure
    • Environment variable overrides for prefixes and event types
    • Validation of service names, version patterns, and digest formats
    • Token requirement enforcement when destination is stale
  • New .github/workflows/ecr-mirror-check.yml: Daily scheduled workflow that:

    • Checks all published releases against ECR Public
    • Optionally dispatches mirror requests for out-of-sync tags via manual trigger
    • Fails if any release is missing or has a mismatched digest
  • Updated service-release.yml:

    • Added mirror-ecr job that runs after publish-image
    • Downloads published image metadata and installs regctl for digest verification
    • Requests ECR mirror via dispatch and verifies the destination digest matches
    • Appends ECR Public references to release notes when mirroring succeeds
    • Made publish-release depend on mirror-ecr to ensure releases only happen when both registries are in sync
  • New docs/design/ecr-mirror-dispatch.md: Design documentation covering:

    • The complete mirroring flow and dispatch contract
    • Setup checklist for enabling the feature
    • Rationale for the cli/ namespace in ECR Public
  • Updated test infrastructure: Added test-ecr-mirror.sh to the repository checks workflow

Implementation Details

  • The script uses regctl for anonymous digest verification, avoiding the need for ECR credentials in this repository
  • Mirroring is skipped gracefully (with a workflow notice) until CLI_MIRROR_DISPATCH_TOKEN is configured
  • Once configured, a failed mirror fails the entire release workflow
  • The dispatch contract validates that source and destination are within expected prefixes and that the source resolves to the expected digest before copying
  • Polling timeout defaults to 900 seconds (15 minutes) with 30-second intervals, both configurable via environment variables
  • The sync command can be used for backfilling existing releases that predate the mirroring feature

https://claude.ai/code/session_01YaJgsq9xTCpMnEhqesr87S

Slim images are published to ghcr.io/supabase/cli/<service> only, so the
CLI cannot pull them through public.ecr.aws like its other images, and
mirror drift keeps surfacing as manifest-not-found failures in dependent
CI. Reuse the mirror machinery and AWS credentials that already live in
supabase/cli instead of provisioning AWS access for this repository.

- scripts/ecr-mirror.sh sends a mirror-slim-image repository_dispatch to
  supabase/cli and polls public.ecr.aws/supabase/cli/<service>:<version>
  anonymously until its index digest matches the published GHCR digest.
  Its sync mode audits every published release and can re-request
  out-of-sync tags, which doubles as the backfill path.
- service-release.yml gains a mirror-ecr job between publish-image and
  publish-release. It skips with a notice until the
  CLI_MIRROR_DISPATCH_TOKEN secret exists; once configured, an
  unverified mirror fails the release, and verified releases list the
  ECR references in their notes.
- ecr-mirror-check.yml runs the sync audit daily.
- docs/design/ecr-mirror-dispatch.md records the dispatch contract the
  supabase/cli handler must implement (digest-preserving copy, payload
  validation, repository creation) and the setup checklist.
- scripts/test-ecr-mirror.sh covers the payload contract, input
  validation, and the token guard, and is wired into repository checks.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YaJgsq9xTCpMnEhqesr87S
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.

2 participants