Skip to content

02 β€” Artifact Registry

← Previous: 01 β€” GCP Project Setup

βœ… Practically free. First 0.5 GB of storage per month is free. A typical Django image is ~200–300 MB, so early on you stay within the free tier. After that, storage costs $0.10/GB/month. Network traffic between Artifact Registry and Cloud Run in the same region is free.

What is Artifact Registry?

Artifact Registry is GCP's private container image registry β€” the place where Docker images are stored before they're deployed. Think of it like Docker Hub, but private and inside your GCP project.

When GitHub Actions builds a Docker image from your code, it pushes it here. When Cloud Run deploys, it pulls the image from here. The image never leaves GCP's network.

What is a Docker image?

A Docker image is a packaged, self-contained snapshot of your application: the Python runtime, all dependencies, your Django code, and the command to start the server β€” all bundled into a single file. Cloud Run takes this image and runs it as a container (a live process).


Create the repository

# Creates a private Docker image registry inside your GCP project.
# This is where GitHub Actions will push built images and Cloud Run will pull from.
# Result: visible at console.cloud.google.com/artifacts β€” the registry URL will be
# southamerica-east1-docker.pkg.dev/mycoolproject-prod/mycoolproject-repo/
gcloud artifacts repositories create mycoolproject-repo \
  --repository-format=docker \
  --location=southamerica-east1

This creates a repository at:

southamerica-east1-docker.pkg.dev/mycoolproject-prod/mycoolproject-repo/

Images pushed here will be named:

southamerica-east1-docker.pkg.dev/mycoolproject-prod/mycoolproject-repo/app:<tag>

Tags used in this guide:

  • latest β€” always points to the most recent build
  • <git-sha> β€” e.g. a3f9c12 β€” unique tag per commit, used for precise rollbacks

Authenticate Docker to push images

Before pushing images from your local machine (first deploy only β€” GitHub Actions handles this automatically afterwards):

# Configures Docker on your local machine to use gcloud credentials when pushing
# to this registry. Run once per machine β€” not needed in GitHub Actions (handled
# by the workflow). Writes a credential helper to ~/.docker/config.json.
gcloud auth configure-docker southamerica-east1-docker.pkg.dev

This updates your local Docker config so it knows to use gcloud credentials when pushing to this registry.