|
| 1 | +# Stage container-debug-support images to the staging location ($_REPO) using |
| 2 | +# both long- and short-form names. On a successful build, long- and short-form images |
| 3 | +# will be pushed to: |
| 4 | +# - $_REPO/$SHORT_SHA tagged with `:latest` |
| 5 | +# - $_REPO tagged with `:$SHORT_SHA` and `:latest`, replacing previously staged images |
| 6 | +# |
| 7 | +# To test: |
| 8 | +# $ env CLOUDSDK_CORE_PROJECT=bdealwis-playground \ |
| 9 | +# gcloud builds submit --config=hack/cloudbuild-staging.yaml \ |
| 10 | +# --substitutions=SHORT_SHA=999999,_REPO=us-central1-docker.pkg.dev/bdealwis-playground/junk/skaffold-debug-support . |
| 11 | +options: |
| 12 | + machineType: 'N1_HIGHCPU_8' |
| 13 | + env: |
| 14 | + - DOCKER_CLI_EXPERIMENTAL=enabled |
| 15 | + |
| 16 | +substitutions: |
| 17 | + _REPO: us-central1-docker.pkg.dev/k8s-skaffold/skaffold-staging/skaffold-debug-support |
| 18 | + _RUNTIMES: go netcore nodejs python |
| 19 | + |
| 20 | +steps: |
| 21 | + # Update buildx to 0.7.1 and configure docker for multi-platform builds with qemu |
| 22 | + - name: gcr.io/cloud-builders/gcloud |
| 23 | + entrypoint: 'bash' |
| 24 | + args: |
| 25 | + - '-eEuo' |
| 26 | + - 'pipefail' |
| 27 | + - '-c' |
| 28 | + - |- |
| 29 | + mkdir -p $$HOME/.docker/cli-plugins |
| 30 | + curl -sLo $$HOME/.docker/cli-plugins/docker-buildx https://github.com/docker/buildx/releases/download/v0.7.1/buildx-v0.7.1.linux-amd64 |
| 31 | + chmod +x $$HOME/.docker/cli-plugins/docker-buildx |
| 32 | + - name: gcr.io/cloud-builders/docker |
| 33 | + args: [info] |
| 34 | + # Install tonistiigi's binfmt extensions for arm64 emulation <https://github.com/tonistiigi/binfmt> |
| 35 | + - name: 'tonistiigi/binfmt@sha256:8de6f2decb92e9001d094534bf8a92880c175bd5dfb4a9d8579f26f09821cfa2' # qemu-6.1.0 |
| 36 | + args: [--install, "arm64"] |
| 37 | + |
| 38 | + ################################################################### |
| 39 | + # Build the images to separate loction in $_REPO to allow easy testing with images from specific commit: |
| 40 | + # skaffold config set --global debug-helpers-registry $_REPO/$SHORT_SHA |
| 41 | + - name: gcr.io/k8s-skaffold/skaffold |
| 42 | + args: [skaffold, build, -p, release, --default-repo, $_REPO/$SHORT_SHA] |
| 43 | + # Copy the images to the short-names for backwards compatibility. |
| 44 | + # Ideally we would just re-invoke Skaffold which should push the just-built |
| 45 | + # long-form images to the short-form names but that isn't working |
| 46 | + # (https://github.com/GoogleContainerTools/skaffold/issues/6957). |
| 47 | + - name: gcr.io/go-containerregistry/gcrane:debug |
| 48 | + entrypoint: /busybox/sh |
| 49 | + args: |
| 50 | + - "-euc" |
| 51 | + - |- |
| 52 | + for runtime in $_RUNTIMES; do |
| 53 | + gcrane copy $_REPO/$SHORT_SHA/skaffold-debug-$$runtime:latest $_REPO/$SHORT_SHA/$$runtime:latest |
| 54 | + done |
| 55 | +
|
| 56 | + ################################################################### |
| 57 | + # Stage the images into $_REPO |
| 58 | + # |
| 59 | + # First copy images into $_REPO using the $SHORT_SHA as tag |
| 60 | + - name: gcr.io/go-containerregistry/gcrane:debug |
| 61 | + entrypoint: /busybox/sh |
| 62 | + args: |
| 63 | + - "-euc" |
| 64 | + - |- |
| 65 | + for runtime in $_RUNTIMES; do |
| 66 | + gcrane copy $_REPO/$SHORT_SHA/skaffold-debug-$$runtime:latest $_REPO/skaffold-debug-$$runtime:$SHORT_SHA |
| 67 | + gcrane copy $_REPO/$SHORT_SHA/$$runtime:latest $_REPO/$$runtime:$SHORT_SHA |
| 68 | + done |
| 69 | + # Then retag long- and short-forms as :latest |
| 70 | + - name: gcr.io/go-containerregistry/gcrane:debug |
| 71 | + entrypoint: /busybox/sh |
| 72 | + args: |
| 73 | + - "-euc" |
| 74 | + - |- |
| 75 | + for runtime in $_RUNTIMES; do |
| 76 | + gcrane tag $_REPO/skaffold-debug-$$runtime:$SHORT_SHA latest |
| 77 | + gcrane tag $_REPO/$$runtime:$SHORT_SHA latest |
| 78 | + done |
| 79 | +
|
| 80 | +# amd64 + arm64 builds typically take about 15 minutes |
| 81 | +timeout: 1200s |
0 commit comments