Can't build and push my image to Google Artifact Registry using BuildPacks
My code to build the image and push it to Artifact Registry:
steps:
# use Buildpacks to create, build and push the container image to Artifact Registry
- name: 'gcr.io/k8s-skaffold/pack'
entrypoint: 'pack'
args: ['build', '--builder=gcr.io/buildpacks/builder', '--publish', '${_REGION}-docker.pkg.dev/${_PROJECT_ID}/${_REPO_ID}/${_IMAGE}:${_TAG}']
The command I run:
gcloud builds submit --region=europe-west1 --config=cloudbuild.yaml
what it returns:
===> DETECTING
[detector] Timer: Detector started at 2024-01-24T06:19:32Z
[detector] 4 of 6 buildpacks participating
[detector] google.go.runtime 0.9.1
[detector] google.go.gopath 0.9.0
[detector] google.go.build 0.9.0
[detector] google.utils.label-image 0.0.2
[detector] Timer: Detector ran for 91.268404ms and ended at 2024-01-24T06:19:32Z
===> RESTORING
[restorer] Timer: Restorer started at 2024-01-24T06:19:32Z
[restorer] Timer: Restorer ran for 343.56µs and ended at 2024-01-24T06:19:32Z
===> BUILDING
[builder] Timer: Builder started at 2024-01-24T06:19:33Z
[builder] === Go - Runtime ([email protected]) ===
[builder] Using runtime version from GOOGLE_RUNTIME_VERSION: 17
[builder] 2024/01/24 06:19:33 [DEBUG] GET https://go.dev/dl/?mode=json
[builder] --------------------------------------------------------------------------------
[builder] failed to build: (error ID: a8a5e01d):
[builder] invalid Go version specified: https://go.dev/dl/?mode=json, You can refer to failed to resolve version matching: 17 for a list of stable Go releases.
[builder] --------------------------------------------------------------------------------
[builder] Sorry your project couldn't be built.
[builder] Our documentation explains ways to configure Buildpacks to better recognise your project:
[builder] -> https://cloud.google.com/docs/buildpacks/overview
[builder] If you think you've found an issue, please report it:
[builder] -> https://github.com/GoogleCloudPlatform/buildpacks/issues/new
[builder] --------------------------------------------------------------------------------
[builder] Timer: Builder ran for 171.666639ms and ended at 2024-01-24T06:19:33Z
[builder] ERROR: failed to build: exit status 1
ERROR: failed to build: executing lifecycle. This may be the result of using an untrusted builder: failed with status code: 51
ERROR
ERROR: build step 0 "gcr.io/k8s-skaffold/pack" failed: step exited with non-zero status: 1
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
BUILD FAILURE: Build step failure: build step 0 "gcr.io/k8s-skaffold/pack" failed: step exited with non-zero status: 1
ERROR: (gcloud.builds.submit) build c21ad7ea-c672-4f33-a87b-75baf7badf67 completed with status "FAILURE"
My project.toml:
[[build.env]]
name = "GOOGLE_RUNTIME_VERSION"
value = "17"
can someone help me understand what is wrong here and how to solve it?
thanks in advance
Maybe try running in the args --trust-builder or enable your build service account to have Artifact registry service account permissions.
@kennethye1 thank you for the suggestions, but it doesn't solve the issue. i think this is related to the Go version
Ah I see, you're using Go. You should fix it with --env GOOGLE_RUNTIME_VERSION=1.21.
You actually need to give the full semver version number for the runtime version, so your project.toml needs to be:
[[build.env]]
name = "GOOGLE_RUNTIME_VERSION"
value = "1.17"