@@ -14,6 +14,9 @@ CONTAINER_RUN = "$(CONTAINER_ENGINE)" run --rm --interactive --tty --volume
14
14
CCRED =\033[0;31m
15
15
CCEND =\033[0m
16
16
17
+ # Docker buildx related settings for multi-arch images
18
+ DOCKER_BUILDX ?= docker buildx
19
+
17
20
.PHONY : all build build-preview help serve
18
21
19
22
help : # # Show this help.
@@ -78,17 +81,17 @@ PLATFORMS ?= linux/arm64,linux/amd64
78
81
docker-push : # # Build a multi-architecture image and push that into the registry
79
82
docker run --rm --privileged tonistiigi/binfmt:qemu-v6.2.0-26@sha256:5bf63a53ad6222538112b5ced0f1afb8509132773ea6dd3991a197464962854e --install all
80
83
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 \
86
89
--push \
87
90
--platform=$(PLATFORMS ) \
88
91
--build-arg HUGO_VERSION=$(HUGO_VERSION ) \
89
92
--tag $(CONTAINER_IMAGE ) \
90
93
-f Dockerfile.cross .
91
- docker buildx stop image-builder
94
+ $( DOCKER_BUILDX ) stop image-builder
92
95
rm Dockerfile.cross
93
96
94
97
container-build : module-check
0 commit comments