This repository contains the necessary scripts and descriptors to setup the infrastructure described in Building multi-architecture container images in Google Cloud reference guide:
- Terraform templates that provision the necessary infrastructure on Google Cloud.
- A Dockerfile to build a Docker image during the tutorial.
You need the following tools to follow the tutorial:
- Git (tested with version
2.25.0
). - Terraform (tested with version
v0.12.20
). - Google Cloud SDK (tested with version
271.0.0
).
To provision the necessary infrastructure, you need to initialize and export the following environment variables:
TF_SERVICE_ACCOUNT_NAME
: Google Cloud service account name that Terraform will use to provision resources.TF_STATE_PROJECT
: Google Cloud project ID that Terraform will use to store the state.TF_STATE_BUCKET
: Google Cloud Storage bucket that Terraform will use to save the state files.GOOGLE_CLOUD_PROJECT
: Google Cloud project ID that will contain the resources for the container image building pipeline.GOOGLE_APPLICATION_CREDENTIALS
: path to the default Google Cloud credentials.
- Change your working directory to the root of this repository.
- Generate the Terraform backend configuration:
./generate-tf-backend.sh
- Change your working directory:
cd terraform
- Inspect the changes that Terraform will apply:
terraform plan
- Apply the changes:
terraform apply
You can now trigger the container image building pipeline:
- Clone the Cloud Source Repository (CSR) that you provisioned with Terraform:
gcloud source repos clone cross-build
- Copy the provided
Dockerfile
and the build-docker-image-trigger.yaml in the directory where you cloned the CSR repository. - Commit the changes:
git add .
- Push the changes to the remote CSR repository:
git push
You can then open the Cloud Build page in the Google Cloud Console to inspect the results.