New to Kestra?
Use blueprints to kickstart your first workflows.
Build Docker images and push them to Google Cloud Artifact Registry with Kestra. Authenticate with short-lived OAuth tokens from a GCP service account.
id: build-gcp-artifact-registry-image
namespace: company.team
tasks:
- id: fetch_auth_token
type: io.kestra.plugin.gcp.auth.OauthAccessToken
projectId: your_gcp_project_id
serviceAccount: "{{ secret('GCP_CREDS') }}"
- id: build
type: io.kestra.plugin.docker.Build
dockerfile: |
FROM python:3.10
RUN pip install --upgrade pip
RUN pip install --no-cache-dir kestra requests "polars[all]"
tags:
- europe-west3-docker.pkg.dev/your_gcp_project_id/kestra/polars:latest
push: true
credentials:
username: oauth2accesstoken
password: "{{ outputs.fetch_auth_token.accessToken.tokenValue }}"
Build a Docker image and publish it to Google Cloud Artifact Registry in a single Kestra flow. This blueprint solves a common CI gap: you need a reproducible container build that authenticates to a private GCP registry without baking long-lived keys into your pipeline. It mints a short-lived OAuth access token from a service account, then builds and pushes a tagged image to a regional Artifact Registry repository, ready for GKE, Cloud Run, or Kubernetes deployments.
fetch_auth_token task (io.kestra.plugin.gcp.auth.OauthAccessToken) reads the service account JSON from a Kestra secret and exchanges it for a short-lived OAuth access token scoped to your projectId.build task (io.kestra.plugin.docker.Build) builds an image from an inline dockerfile (here a Python 3.10 base with kestra, requests, and polars), then with push: true ships it to Artifact Registry.credentials block: the username oauth2accesstoken plus the token from {{ outputs.fetch_auth_token.accessToken.tokenValue }} as the password.tags pin the regional registry host, project, repository, and tag (for example europe-west3-docker.pkg.dev/your_gcp_project_id/kestra/polars:latest).Artifact Registry stores images but does not build them or decide when a build runs. Kestra fills that gap: trigger builds on Git pushes, schedules, or upstream flow events, add retries and errors handling for flaky network or registry calls, capture full execution lineage and logs, and keep the whole pipeline as declarative, version-controlled YAML. Secrets stay out of the flow and tokens stay short-lived.
GCP_CREDS: the GCP service account JSON used by io.kestra.plugin.gcp.auth.OauthAccessToken.GCP_CREDS secret with your service account JSON.projectId in fetch_auth_token to your GCP project.tags to your region, project, repository, and tag.dockerfile to your build, then run the flow.dockerfile with a file checked out from Git.