Skip to content

ci: also publish release images to the China mirror - #6

Closed
zhanghaohit wants to merge 1 commit into
mainfrom
ci/mirror-to-tcr
Closed

zhanghaohit wants to merge 1 commit into
mainfrom
ci/mirror-to-tcr

Conversation

@zhanghaohit

Copy link
Copy Markdown
Collaborator

What

After each Docker Hub push to 4pdosc/*, copy the same image to modelsphere.tencentcloudcr.com/4pdosc/* under the same tags. Pulling from mainland China, Docker Hub is slow or unreachable; the mirror is a public namespace, so docker pull modelsphere.tencentcloudcr.com/4pdosc/<image>:<tag> works anonymously.

How

  • One extra step after each docker/build-push-action step that pushes to Docker Hub. It reuses that step's own tag list and run condition, and copies by the digest that step reports, so it mirrors exactly what was pushed. Tags for other registries in the same list (e.g. ghcr.io) are left alone.
  • The copy uses crane copy, which copies manifests verbatim: both registries serve the same digest. docker buildx imagetools create was tried first and rejected -- given a single manifest (an image built with provenance: false), it wraps it in a new index and changes the digest.
  • crane is a pinned release (v0.20.6), verified against its sha256 before use.
  • Its own step, after the Docker Hub push: if the mirror is down, this step fails but the Docker Hub release is already complete.
  • Uses the org secrets TCR_USERNAME / TCR_TOKEN; without them the step is skipped with a notice.

Testing

  • The workflow file parses and the digest reference resolves to the build step.
  • The step's script, taken verbatim from this file, was run on a Linux host with a fake RUNNER_TEMP: crane download + checksum, login, and copy of both tags of an existing release, digest unchanged.
  • crane copy was checked to keep the digest for both a multi-platform index and a single plain manifest.

Every image this workflow pushes to Docker Hub's 4pdosc is now copied to
modelsphere.tencentcloudcr.com/4pdosc as well, under the same tags, for
users who pull from mainland China, where Docker Hub is slow or blocked.

The copy is by digest with crane, which copies manifests verbatim, so both
registries serve identical bytes. (buildx imagetools create was ruled out:
given a single manifest, such as an image built with provenance disabled,
it wraps it in a new index and the digest changes.) crane is a pinned
release, checked against its sha256.

It runs as its own step after the Docker Hub push, so a mirror outage
fails that step without stopping or half-finishing the Docker Hub release.
Without the org secrets TCR_USERNAME / TCR_TOKEN it is skipped with a
notice.
@zhanghaohit

Copy link
Copy Markdown
Collaborator Author

Closing: measured from GitHub-hosted runners, pushing to the mainland-China registry runs at well under 1 MB/s (a 740 MiB image had not finished after more than an hour), so mirroring from the release job would stall releases. The mirror will be fed from a host inside China instead.

@zhanghaohit
zhanghaohit deleted the ci/mirror-to-tcr branch October 20, 2026 05:39
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