GCP Artifact Registry Image
The gcp-artifact-registry-image recipe builds a Docker image and pushes it to Google Artifact Registry. It has no deploy step.
Use it for images that something else runs:
- Shared base images that other Dockerfiles build
FROM - Images deployed by another service, such as a Cloud Run (from image) service or a sidecar
- Tooling images used in CI or by Cloud Run Jobs managed outside Pilum
Prerequisites
- Google Cloud SDK installed and authenticated
- Docker installed and authenticated to Artifact Registry
- An Artifact Registry Docker repository
# Authenticate Docker to the registry hostgcloud auth logingcloud auth configure-docker us-central1-docker.pkg.dev
# Create the repository (once)gcloud artifacts repositories create platform-images \ --repository-format docker \ --location us-central1 \ --project my-gcp-projectService Configuration
name: go-basetype: gcp-artifact-registry-imageproject: my-gcp-projectregion: us-central1registry_name: platform-imagestemplate: go-base.dockerfile
image_name: go-base # optional; defaults to nameversion: v1.3.0 # optional; used when --tag is not givenThe Dockerfile is _templates/go-base.dockerfile at the project root. This config publishes:
us-central1-docker.pkg.dev/my-gcp-project/platform-images/go-base:v1.3.0To compile code on the host before the Docker build, add a build block as for any container recipe. Without build.cmd, the build binary step is skipped and the Dockerfile does all the work. See Build Configuration.
Required Fields
| Field | Description |
|---|---|
name | Pilum service name |
project | GCP project ID |
region | Artifact Registry location, e.g. us-central1, or a multi-region such as us |
registry_name | Artifact Registry repository name. Use the bare name, e.g. platform-images, not a host or path. |
template | Dockerfile template name, relative to _templates/ |
Optional Fields
| Field | Type | Default | Description |
|---|---|---|---|
image_name | string | name | Image name within the repository |
version | string | latest | Image tag used when --tag is not given |
Image Name and Tag
The image reference is:
<region>-docker.pkg.dev/<project>/<registry_name>/<image_name or name>:<tag>The tag is chosen in this order:
--tagon the command lineversion:inpilum.yamllatest
version: lets you pin a deliberate version in source, while CI can still override it with --tag. The image is built with both the resolved tag and latest, but only the resolved tag is pushed. To move latest in the registry, run with --tag latest (or leave both --tag and version unset).
Deployment Steps
- build binary — Runs
build.cmdin the service directory (skipped whencmdis empty) - build docker image —
docker build -f ./_templates/<template>from the project root - publish to registry —
docker pushof the resolved tag
pilum deploy and pilum publish both run all three steps. pilum build runs the first two; pilum push runs only the push.
Example Commands
# Build and push using version: from pilum.yamlpilum deploy go-base
# Build and push a specific tagpilum publish go-base --tag v1.4.0
# Build locally without pushingpilum build go-base
# Preview the docker commandspilum dry-run go-baseGenerated Commands
For the configuration above, with no --tag:
docker build \ -t us-central1-docker.pkg.dev/my-gcp-project/platform-images/go-base:v1.3.0 \ -t us-central1-docker.pkg.dev/my-gcp-project/platform-images/go-base:latest \ --build-arg SERVICE_NAME=services/go-base \ -f ./_templates/go-base.dockerfile .
docker push us-central1-docker.pkg.dev/my-gcp-project/platform-images/go-base:v1.3.0SERVICE_NAME is the service directory relative to the project root. If the service sets top-level env_vars, they are also passed to docker build through --build-arg.
Using the Image From Other Services
A Cloud Run (from image) service deploys whatever reference its image field names:
name: mcp-controllertype: gcp-cloud-run-from-imageproject: my-gcp-projectregion: us-central1image: us-central1-docker.pkg.dev/my-gcp-project/platform-images/mcp-controller:v1.0.0Publish the image first, then deploy the services that use it, as two runs:
pilum publish mcp-controller-image --tag v1.0.0pilum deploy mcp-controllerThere is nothing to roll back, and pilum status, pilum logs and pilum rollback do not apply to this recipe.
Troubleshooting
Push Denied
denied: Permission "artifactregistry.repositories.uploadArtifacts" deniedRun gcloud auth configure-docker <region>-docker.pkg.dev for the repository’s host, and make sure your account has roles/artifactregistry.writer on the repository.
Repository Not Found
name unknown: Repository "platform-images" not foundCreate the repository in the same region and project (see Prerequisites), and check that registry_name is the bare repository name.
Service Built but Never Deployed
If you expected a deploy, check the service’s type. This recipe has no deploy step. Use gcp-cloud-run, gcp-cloud-run-job or gcp-mig-container to deploy what you build.
Next Steps
- GCP Cloud Run (from image) — Deploy a prebuilt image
- GCP Cloud Run — Build and deploy in one pipeline
- Build Configuration — Host builds and Dockerfile templates
- Monorepo Deployments — Dependencies and waves