Skip to content

perf(ci): cache the release image locally during the crane copy#9702

Open
eliotlim wants to merge 1 commit into
developfrom
feat/ci/cache-release-image-locally
Open

perf(ci): cache the release image locally during the crane copy#9702
eliotlim wants to merge 1 commit into
developfrom
feat/ci/cache-release-image-locally

Conversation

@eliotlim

@eliotlim eliotlim commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Problem

crane landed in #9690, but it copies the release image GHCR to ECR registry-to-registry, so the image never lands on the runner's docker daemon. The "Copy Static Assets" step extracts apps/frontend/dist with docker run, which then pulls the whole ~22-layer image itself. That turned a ~12s extract into ~96s on release 7.34.4 (run 28495610216, step 13). The Datadog sourcemaps step beside it is only ~1s, so the cost is entirely the pull, not the uploads.

Solution

Pull the image in the background while crane copy runs (independent transfers of the same image), then docker tag it as the ECR ref locally. By the time the static-assets step runs the image is already on the daemon, so docker run does no pull and the extract drops back to ~12s. The pull now hides behind the ~37s crane copy instead of adding to the deploy's critical path.

Breaking Changes

  • Yes - this PR contains breaking changes
  • No - CI only, no app or API changes

Improvements:

  • The static-assets extract no longer re-pulls the whole image (~96s down to ~12s per app deploy).

Tests

This only runs on release-tagged deploys (the crane reuse path), so a branch push can't exercise it (stg-alt2 builds from scratch). Watch the next release's app deploy: "Copy pre-built image to ECR" should show a docker pull running alongside crane, and "Copy Static Assets" should have no "Pulling fs layer" lines.

Deploy Notes

None.

The ECR copy uses crane (registry-to-registry), so the image never lands
on the runner's docker daemon. The static-assets step extracts
apps/frontend/dist with `docker run`, so it then pulled the whole
~22-layer image itself — a ~12s extract became ~96s (run 28495610216,
step 13). crane hadn't removed the pull, only moved it downstream.

Pull the image in the background while crane copies to ECR (independent
transfers of the same image), then tag it as the ECR ref locally. By the
time the static-assets step runs the image is already on the daemon, so
`docker run` does no pull and the extract drops back to ~12s. The pull is
now hidden behind the ~37s crane copy instead of adding to the deploy's
critical path.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@eliotlim
eliotlim requested review from a team and Copilot July 3, 2026 09:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot couldn't run its full agentic review because no GitHub Actions runner was available. Make sure your repository has a runner available to run Copilot's review, or add a copilot-setup-steps.yml file specifying one with the runs-on attribute. See the docs for more details.

Improves release-tag deploy CI performance by ensuring the release image is present on the GitHub Actions runner’s local Docker daemon while still doing a fast registry-to-registry copy to ECR.

Changes:

  • Starts a background docker pull of the GHCR release image while crane copy runs to ECR.
  • Waits for the pull to finish, then tags the locally pulled image with the ECR reference used by later steps.
  • Expands inline documentation explaining why both transfers are needed and how this reduces the critical path.

Comment on lines +230 to +234
docker pull "$SRC_IMAGE" &
pull_pid=$!
crane copy "$SRC_IMAGE" "$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
wait "$pull_pid"
docker tag "$SRC_IMAGE" "$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
Comment on lines 232 to +234
crane copy "$SRC_IMAGE" "$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
wait "$pull_pid"
docker tag "$SRC_IMAGE" "$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
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