From fb5e53aef5271fd6f030d6232cc82f69fd2f56a2 Mon Sep 17 00:00:00 2001 From: vitt-bagal <31851690+vitt-bagal@users.noreply.github.com> Date: Tue, 24 Mar 2020 12:12:33 +0530 Subject: [PATCH 1/3] Add multiarch dockerfile build multiarch image with all arch specified by `--platform` option to docker buildx build --- Dockerfile.multiarch | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Dockerfile.multiarch diff --git a/Dockerfile.multiarch b/Dockerfile.multiarch new file mode 100644 index 000000000..0a40bc083 --- /dev/null +++ b/Dockerfile.multiarch @@ -0,0 +1,14 @@ +FROM --platform=$BUILDPLATFORM golang:1.13.3 AS builder +ARG TARGETPLATFORM +ARG BUILDPLATFORM +WORKDIR /code +ADD . /code/ + +RUN cd /code/ && GOARCH=$(echo $TARGETPLATFORM | cut -f2 -d '/') make build + +FROM gcr.io/distroless/static:latest +LABEL maintainers="Kubernetes Authors" +LABEL description="CSI Node driver registrar" + +COPY --from=builder /code/bin/csi-node-driver-registrar csi-node-driver-registrar +ENTRYPOINT ["/csi-node-driver-registrar"] From 0c60f8ea930d89b5b913c339900da207b5358369 Mon Sep 17 00:00:00 2001 From: vitt-bagal <31851690+vitt-bagal@users.noreply.github.com> Date: Tue, 24 Mar 2020 12:17:28 +0530 Subject: [PATCH 2/3] Automate Container Image Builds Using GCB Adding a GCB(Google Cloud Build) config file to automate build and push(to staging gcr.io/k8s-staging-csi) of multiarch docker image --- cloudbuild.yaml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 cloudbuild.yaml diff --git a/cloudbuild.yaml b/cloudbuild.yaml new file mode 100644 index 000000000..7810aac68 --- /dev/null +++ b/cloudbuild.yaml @@ -0,0 +1,28 @@ +# See https://cloud.google.com/cloud-build/docs/build-config + +# this must be specified in seconds. If omitted, defaults to 600s (10 mins) +timeout: 1200s +# this prevents errors if you don't use both _GIT_TAG and _PULL_BASE_REF, +# or any new substitutions added in the future. +options: + substitution_option: ALLOW_LOOSE +steps: + - name: 'gcr.io/k8s-testimages/gcb-docker-gcloud:v20190906-745fed4' + entrypoint: 'bash' + env: + - DOCKER_CLI_EXPERIMENTAL=enabled + - VERSION=$_GIT_TAG + - BASE_REF=$_PULL_BASE_REF + args: + - '-c' + - | + docker buildx create --use --name multiarchimage-builder \ + && docker buildx build --push -t gcr.io/k8s-staging-csi/csi-node-driver-registrar:latest --platform=linux/amd64,linux/s390x -f Dockerfile.multiarch . +substitutions: + # _GIT_TAG will be filled with a git-based tag for the image, of the form vYYYYMMDD-hash, and + # can be used as a substitution + _GIT_TAG: '12345' + # _PULL_BASE_REF will contain the ref that was pushed to to trigger this build - + # a branch like 'master' or 'release-0.2', or a tag like 'v0.2'. + _PULL_BASE_REF: 'master' + From 6604f7c617ece0f5537e8938e6c7cfecb6a12703 Mon Sep 17 00:00:00 2001 From: vitt-bagal <31851690+vitt-bagal@users.noreply.github.com> Date: Wed, 25 Mar 2020 10:38:37 +0530 Subject: [PATCH 3/3] Added readme of image pushing --- cloudbuild.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloudbuild.yaml b/cloudbuild.yaml index 7810aac68..883e4d8e2 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -1,4 +1,4 @@ -# See https://cloud.google.com/cloud-build/docs/build-config +# See https://github.com/kubernetes/test-infra/blob/master/config/jobs/image-pushing/README.md for more details on image pushing process # this must be specified in seconds. If omitted, defaults to 600s (10 mins) timeout: 1200s