|
1 |
| -# See https://cloud.google.com/cloud-build/docs/build-config |
| 1 | +# K8s infra build example: https://github.com/kubernetes/test-infra/blob/master/config/jobs/image-pushing/README.md |
| 2 | +# GCloud build docs: https://cloud.google.com/cloud-build/docs/build-config |
| 3 | +# Builds go to https://console.cloud.google.com/gcr/images/k8s-staging-sig-storage/GLOBAL |
| 4 | +# Build logs in https://testgrid.k8s.io/sig-storage-image-build |
2 | 5 | timeout: 3000s
|
3 | 6 | options:
|
4 |
| - substitution_option: ALLOW_LOOSE |
| 7 | + substitution_option: 'ALLOW_LOOSE' |
| 8 | + machineType: 'E2_HIGHCPU_8' |
| 9 | +substitutions: |
| 10 | + # K8s provides custom substitutions _GIT_TAG and _PULL_BASE_REF: |
| 11 | + # https://github.com/kubernetes/test-infra/blob/master/config/jobs/image-pushing/README.md#custom-substitutions |
| 12 | + _GIT_TAG: '12345' # e.g., vYYYYMMDD-hash, vYYYYMMDD-tag, or vYYYYMMDD-tag-n-ghash |
| 13 | + _PULL_BASE_REF: 'master' # e.g., master or release-0.2 for a PR merge, or v0.2 for a tag |
| 14 | + # COSI substitutions: |
| 15 | + _IMAGE: objectstorage-sidecar |
| 16 | + _PLATFORMS: linux/amd64,linux/arm64 # add more platforms here if desired |
5 | 17 | steps:
|
6 |
| -- name: "gcr.io/k8s-staging-test-infra/gcb-docker-gcloud:v20221214-1b4dd4d69a" |
7 |
| - entrypoint: make |
8 |
| - args: ['build'] |
9 |
| - env: |
10 |
| - - GIT_TAG=${_GIT_TAG} |
11 |
| - - PULL_BASE_REF=${_PULL_BASE_REF} |
12 |
| -- name: "gcr.io/k8s-staging-test-infra/gcb-docker-gcloud:v20221214-1b4dd4d69a" |
13 |
| - entrypoint: make |
14 |
| - args: ['push'] |
15 |
| - env: |
16 |
| - - GIT_TAG=${_GIT_TAG} |
17 |
| - - PULL_BASE_REF=${_PULL_BASE_REF} |
| 18 | + # based on k8s infra build example and modified to use docker buildx |
| 19 | + # buildx refs: https://github.com/docker/buildx/blob/master/docs/reference/buildx.md |
| 20 | + - id: set-up-multi-arch-builder-as-default |
| 21 | + name: gcr.io/cloud-builders/docker |
| 22 | + args: ["buildx", "create", "--use", "--name", "multi-arch", "--platform=${_PLATFORMS}"] |
| 23 | + - id: bootstrap-multi-arch-builder |
| 24 | + name: gcr.io/cloud-builders/docker |
| 25 | + args: ["buildx", "inspect", "--bootstrap"] |
| 26 | + - id: do-multi-arch-build |
| 27 | + name: gcr.io/cloud-builders/docker |
| 28 | + args: |
| 29 | + - buildx |
| 30 | + - build |
| 31 | + - --push # --load doesn't work with multi-platform builds, so just push from docker build |
| 32 | + - --platform=${_PLATFORMS} |
| 33 | + - --tag=gcr.io/k8s-staging-sig-storage/${_IMAGE}:${_GIT_TAG} |
| 34 | + # using _PULL_BASE_REF as a tag will often just build and overwrite the same 'master' tag, |
| 35 | + # BUT! if the commit has a git tag, it will build that tag instead. this mechanism allows |
| 36 | + # creating the semver-tagged images that will be auto-promoted to release |
| 37 | + - --tag=gcr.io/k8s-staging-sig-storage/${_IMAGE}:${_PULL_BASE_REF} |
| 38 | + - --tag=gcr.io/k8s-staging-sig-storage/${_IMAGE}:latest |
| 39 | + - . |
0 commit comments