Add DOCKER_BUILDX to inject path of buildx binary
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
This commit is contained in:
parent
55c54a6878
commit
04708a1a83
15
Makefile
15
Makefile
|
|
@ -14,6 +14,9 @@ CONTAINER_RUN = "$(CONTAINER_ENGINE)" run --rm --interactive --tty --volume
|
||||||
CCRED=\033[0;31m
|
CCRED=\033[0;31m
|
||||||
CCEND=\033[0m
|
CCEND=\033[0m
|
||||||
|
|
||||||
|
# Docker buildx related settings for multi-arch images
|
||||||
|
DOCKER_BUILDX ?= docker buildx
|
||||||
|
|
||||||
.PHONY: all build build-preview help serve
|
.PHONY: all build build-preview help serve
|
||||||
|
|
||||||
help: ## Show this help.
|
help: ## Show this help.
|
||||||
|
|
@ -78,17 +81,17 @@ PLATFORMS ?= linux/arm64,linux/amd64
|
||||||
docker-push: ## Build a multi-architecture image and push that into the registry
|
docker-push: ## Build a multi-architecture image and push that into the registry
|
||||||
docker run --rm --privileged tonistiigi/binfmt:qemu-v6.2.0-26@sha256:5bf63a53ad6222538112b5ced0f1afb8509132773ea6dd3991a197464962854e --install all
|
docker run --rm --privileged tonistiigi/binfmt:qemu-v6.2.0-26@sha256:5bf63a53ad6222538112b5ced0f1afb8509132773ea6dd3991a197464962854e --install all
|
||||||
docker version
|
docker version
|
||||||
docker buildx version
|
$(DOCKER_BUILDX) version
|
||||||
docker buildx create --use --name=image-builder 2>/dev/null || docker buildx use --default image-builder
|
$(DOCKER_BUILDX) inspect image-builder > /dev/null 2>&1 || $(DOCKER_BUILDX) create --name image-builder --use
|
||||||
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
|
# copy existing Dockerfile and insert --platform=${TARGETPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
|
||||||
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
|
sed -e 's/\(^FROM\)/FROM --platform=\$$\{TARGETPLATFORM\}/' Dockerfile > Dockerfile.cross
|
||||||
docker buildx build \
|
$(DOCKER_BUILDX) build \
|
||||||
--push \
|
--push \
|
||||||
--platform=$(PLATFORMS) \
|
--platform=$(PLATFORMS) \
|
||||||
--build-arg HUGO_VERSION=$(HUGO_VERSION) \
|
--build-arg HUGO_VERSION=$(HUGO_VERSION) \
|
||||||
--tag $(CONTAINER_IMAGE) \
|
--tag $(CONTAINER_IMAGE) \
|
||||||
-f Dockerfile.cross .
|
-f Dockerfile.cross .
|
||||||
docker buildx stop image-builder
|
$(DOCKER_BUILDX) stop image-builder
|
||||||
rm Dockerfile.cross
|
rm Dockerfile.cross
|
||||||
|
|
||||||
container-build: module-check
|
container-build: module-check
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,8 @@ steps:
|
||||||
- -c
|
- -c
|
||||||
- |
|
- |
|
||||||
gcloud auth configure-docker \
|
gcloud auth configure-docker \
|
||||||
&& make container-push
|
&& apk add sed \
|
||||||
|
&& make docker-push
|
||||||
substitutions:
|
substitutions:
|
||||||
# _GIT_TAG will be filled with a git-based tag for the image, of the form vYYYYMMDD-hash, and
|
# _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
|
# can be used as a substitution
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue