Cloud Build doesn't hydrate the BUILDPLATFORM env
Since https://github.com/GoogleCloudPlatform/microservices-demo/pull/2589 was introduced, it broke the releasing process, though I just noticed now trying to perform a release.
The release build fails with errors like:
Step 1/14 : FROM --platform=$BUILDPLATFORM eclipse-temurin:21.0.5_11-jdk@sha256:a20cfa6afdbf57ff2c4de77ae2d0e3725a6349f1936b5ad7c3d1b06f6d1b840a AS builder
failed to parse platform : "" is an invalid component of "": platform specifier component must match "^[A-Za-z0-9_-]+$": invalid argument
It looks like Cloud Build may support BuildKit but I was not successful in finding a solution to enable BuildKit via gcloud builds submit, which is what the releasing process does: https://github.com/GoogleCloudPlatform/microservices-demo/blob/main/docs/releasing/make-docker-images.sh#L43
As a temporary workaround, to be able to do the latest release (https://github.com/GoogleCloudPlatform/microservices-demo/pull/2983) I had to git revert (and then subsequently git cherry-pick) the commit introducing BUILDPLATFORM (https://github.com/GoogleCloudPlatform/microservices-demo/commit/916eeac8e730f26a5a11d80dba17d65257fa749a)
cc: @mathieu-benoit, since that was your PR, any potential ideas here?
Ouch, sorry about that, I'm not using Cloud Build unfortunately, I'm seeing some pointers like these (very old):
- https://github.com/GoogleCloudPlatform/solutions-build-multi-architecture-images-tutorial/blob/master/terraform/cloud-build/build-docker-image-trigger.yaml
- https://stackoverflow.com/questions/57175062/using-docker-buildkit-on-google-cloud-build
Which one have you tried? Maybe you can get some support internally to see what needs to be done in your Cloud Build definition?
I just started investigating arm64 support in this set of services for a solution we are working on , so it is funny to bump into you here @mathieu-benoit .... I am doing the following in my cloudbuild.yaml to enable multiplatform builds in Cloud Build @bourgeoisor , not sure if it is helpful :
steps:
- name: 'gcr.io/cloud-builders/docker'
args: ['buildx', 'create', '--use']
- name: 'gcr.io/cloud-builders/docker'
args: ['buildx', 'build', '--platform=linux/arm64,linux/amd64', '-t', 'us-central1-docker.pkg.dev/$PROJECT_ID/docker/multi-arch-test:cloudbuild', '--push', '.']