Skip to content

Migrate cloud-build-docker module from GCR to Artifact Registry#31

Closed
jwbron wants to merge 2 commits into
mainfrom
migrate-cloud-build-docker-to-artifact-registry
Closed

Migrate cloud-build-docker module from GCR to Artifact Registry#31
jwbron wants to merge 2 commits into
mainfrom
migrate-cloud-build-docker-to-artifact-registry

Conversation

@jwbron
Copy link
Copy Markdown
Contributor

@jwbron jwbron commented Feb 4, 2026

Summary

  • Migrate cloud-build-docker module from deprecated GCR (gcr.io) to Artifact Registry
  • Add repository variable to specify the Artifact Registry repository name (defaults to docker-images)
  • Update image URI format from gcr.io/{project}/{image} to {region}-docker.pkg.dev/{project}/{repo}/{image}
  • Update gcloud commands in build_image.py to use Artifact Registry APIs
  • Add validation with helpful error message if repository doesn't exist

Breaking Changes

Manual setup required: Users must create an Artifact Registry Docker repository before using this module:

gcloud artifacts repositories create <repository-name> \
  --repository-format=docker \
  --location=<region> \
  --project=<project-id>

Example:

gcloud artifacts repositories create docker-images \
  --repository-format=docker \
  --location=us-central1 \
  --project=your-project

If the repository doesn't exist, the module will fail with a clear error message showing the exact command needed.

Test plan

verified on this branch: https://github.com/Khan/internal-services/pull/453

  • Verify Artifact Registry repository exists in target project
  • Run module with a test image build
  • Verify image appears in Artifact Registry console
  • Verify outputs contain correct Artifact Registry URIs
  • Test cache pull/push functionality works with new registry
  • Test error message when repository doesn't exist

🤖 Generated with Claude Code

jwbron and others added 2 commits February 4, 2026 10:27
GCR (gcr.io) is deprecated. This updates the module to use Artifact
Registry instead, which is Google's recommended container registry.

Changes:
- Add `repository` variable for Artifact Registry repository name
- Update image URI format from gcr.io/{project}/{image} to
  {region}-docker.pkg.dev/{project}/{repo}/{image}
- Update gcloud commands in build_image.py to use `gcloud artifacts`
  instead of `gcloud container images`
- Update documentation and examples with new URI format

Breaking change: Users must create an Artifact Registry repository
before using this module.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…xist

Validates that the repository exists before attempting to build,
providing a clear error message with the gcloud command to create it.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@jwbron jwbron marked this pull request as ready for review February 4, 2026 19:12
@jwbron jwbron requested a review from a team February 4, 2026 19:12
Copy link
Copy Markdown
Member

@csilvers csilvers left a comment

Choose a reason for hiding this comment

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

Great!, seems straightforward enough. It's sad that terraform can't manage the existence of the container registry repository, but at least you have a clear error message.

I'm wondering if we can have a less generic name for the repository, but otherwise no concerns on my end.

project_id = var.project_id
image_tag_suffix = "latest"
region = var.region
repository = "docker-images" # Artifact Registry repository (must exist)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is a really generic name. Can we call it something more specific? If this is only going to be used for deploys, we could call it deploy-images.


Before running this example, ensure you have:

1. An Artifact Registry Docker repository created:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is that not something that terraform can manage for us?

@jwbron jwbron closed this Apr 10, 2026
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