Skip to content

Commit 8f05238

Browse files
authored
Merge pull request #38285 from dims/add-DOCKER_BUILDX-to-inject-path-of-buildx-binary
Add DOCKER_BUILDX to inject path of buildx binary
2 parents 5ba3457 + 9876dc1 commit 8f05238

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

Makefile

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ CONTAINER_RUN = "$(CONTAINER_ENGINE)" run --rm --interactive --tty --volume
1414
CCRED=\033[0;31m
1515
CCEND=\033[0m
1616

17+
# Docker buildx related settings for multi-arch images
18+
DOCKER_BUILDX ?= docker buildx
19+
1720
.PHONY: all build build-preview help serve
1821

1922
help: ## Show this help.
@@ -78,17 +81,17 @@ PLATFORMS ?= linux/arm64,linux/amd64
7881
docker-push: ## Build a multi-architecture image and push that into the registry
7982
docker run --rm --privileged tonistiigi/binfmt:qemu-v6.2.0-26@sha256:5bf63a53ad6222538112b5ced0f1afb8509132773ea6dd3991a197464962854e --install all
8083
docker version
81-
docker buildx version
82-
docker buildx create --use --name=image-builder 2>/dev/null || docker buildx use --default image-builder
83-
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
84-
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
85-
docker buildx build \
84+
$(DOCKER_BUILDX) version
85+
$(DOCKER_BUILDX) inspect image-builder > /dev/null 2>&1 || $(DOCKER_BUILDX) create --name image-builder --use
86+
# copy existing Dockerfile and insert --platform=${TARGETPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
87+
sed -e 's/\(^FROM\)/FROM --platform=\$$\{TARGETPLATFORM\}/' Dockerfile > Dockerfile.cross
88+
$(DOCKER_BUILDX) build \
8689
--push \
8790
--platform=$(PLATFORMS) \
8891
--build-arg HUGO_VERSION=$(HUGO_VERSION) \
8992
--tag $(CONTAINER_IMAGE) \
9093
-f Dockerfile.cross .
91-
docker buildx stop image-builder
94+
$(DOCKER_BUILDX) stop image-builder
9295
rm Dockerfile.cross
9396

9497
container-build: module-check

cloudbuild.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# See https://cloud.google.com/cloud-build/docs/build-config
22

33
# this must be specified in seconds. If omitted, defaults to 600s (10 mins)
4-
timeout: 1200s
4+
timeout: 9000s
55
# this prevents errors if you don't use both _GIT_TAG and _PULL_BASE_REF,
66
# or any new substitutions added in the future.
77
options:
88
substitution_option: ALLOW_LOOSE
9+
machineType: 'E2_HIGHCPU_8'
910
steps:
1011
# It's fine to bump the tag to a recent version, as needed
1112
- name: "gcr.io/k8s-staging-test-infra/gcb-docker-gcloud:v20220830-45cbff55bc"
@@ -20,7 +21,8 @@ steps:
2021
- -c
2122
- |
2223
gcloud auth configure-docker \
23-
&& make container-push
24+
&& apk add sed \
25+
&& make docker-push
2426
substitutions:
2527
# _GIT_TAG will be filled with a git-based tag for the image, of the form vYYYYMMDD-hash, and
2628
# can be used as a substitution

0 commit comments

Comments
 (0)