@@ -7,26 +7,6 @@ BUILDX_DIR=$(realpath $(CURDIR)/../src/github.com/docker/buildx)
77GEN_STATIC_VER =$(shell ./gen-static-ver $(CLI_DIR ) $(VERSION ) )
88HASH_CMD =docker run -v $(CURDIR ) :/sum -w /sum debian:jessie bash hash_files
99DIR_TO_HASH: =build/linux
10- DOCKER_CLI_GOLANG_IMG =golang:$(GO_VERSION )
11-
12- DOCKER_BUILD_OPTS =
13-
14- ifneq ($(strip $(CONTAINERD_VERSION ) ) ,)
15- # Set custom build-args to override the containerd version to build for static
16- # packages. The Dockerfile for 20.10 and earlier used CONTAINERD_COMMIT, later
17- # versions use CONTAINERD_VERSION. We can remove CONTAINERD_VERSION once 20.10.x
18- # reaches EOL.
19- DOCKER_BUILD_OPTS +=--build-arg=CONTAINERD_VERSION=$(CONTAINERD_VERSION )
20- DOCKER_BUILD_OPTS +=--build-arg=CONTAINERD_COMMIT=$(CONTAINERD_VERSION )
21- endif
22-
23- ifneq ($(strip $(RUNC_VERSION ) ) ,)
24- # Set custom build-args to override the runc version to build for static packages.
25- # The Dockerfile for 20.10 and earlier used RUNC_COMMIT, later versions use
26- # RUNC_VERSION. We can remove RUNC_COMMIT once 20.10.x reaches EOL.
27- DOCKER_BUILD_OPTS +=--build-arg=RUNC_VERSION=$(RUNC_VERSION )
28- DOCKER_BUILD_OPTS +=--build-arg=RUNC_COMMIT=$(RUNC_VERSION )
29- endif
3010
3111.PHONY : help
3212help : # # show make targets
@@ -36,83 +16,47 @@ help: ## show make targets
3616clean : # # remove build artifacts
3717 [ ! -d build ] || $(CHOWN ) -R $(shell id -u) :$(shell id -g) build
3818 $(RM ) -r build
39- -docker builder prune -f --filter until=24h
4019
4120.PHONY : static
42- static : static-linux cross-mac cross-win cross-arm # # create all static packages
21+ static : static-linux static-darwin static-windows # # create common static packages
4322
4423.PHONY : static-linux
45- static-linux : static-cli static-engine static-buildx-plugin # # create tgz
46- mkdir -p build/linux/docker
47- cp $(CLI_DIR ) /build/docker build/linux/docker/
48- for f in dockerd containerd ctr containerd-shim containerd-shim-runc-v2 docker-init docker-proxy runc; do \
49- cp -L $(ENGINE_DIR ) /bundles/binary-daemon/$$ f build/linux/docker/$$ f; \
50- done
51- tar -C build/linux -c -z -f build/linux/docker-$(GEN_STATIC_VER ) .tgz docker
52-
53- # extra binaries for running rootless
54- mkdir -p build/linux/docker-rootless-extras
55- for f in rootlesskit rootlesskit-docker-proxy dockerd-rootless.sh dockerd-rootless-setuptool.sh vpnkit; do \
56- if [ -f $(ENGINE_DIR)/bundles/binary-daemon/$$f ]; then \
57- cp -L $(ENGINE_DIR)/bundles/binary-daemon/$$f build/linux/docker-rootless-extras/$$f; \
58- fi \
59- done
60- tar -C build/linux -c -z -f build/linux/docker-rootless-extras-$(GEN_STATIC_VER).tgz docker-rootless-extras
61-
62- # buildx
63- tar -C $(BUILDX_DIR)/bin -c -z -f build/linux/docker-buildx-plugin-$(DOCKER_BUILDX_REF:v%=%).tgz docker-buildx
24+ static-linux : static-linux/amd64 static-linux/arm64 # # create common static linux packages
25+
26+ .PHONY : static-darwin
27+ static-darwin : static-darwin/amd64 static-darwin/arm64 # # create common static darwin packages
28+
29+ .PHONY : static-windows
30+ static-windows : static-windows/amd64 # # create common static windows packages
31+
32+ .PHONY : static-linux/%
33+ static-linux/% : # # create linux static packages for the specified architecture
34+ $(MAKE ) build-static TARGETPLATFORM=linux/$*
35+
36+ .PHONY : static-darwin/%
37+ static-darwin/% : # # create darwin static packages for the specified architecture
38+ $(MAKE ) build-static TARGETPLATFORM=darwin/$*
39+
40+ .PHONY : static-windows/%
41+ static-windows/% : # # create windows static packages for the specified architecture
42+ $(MAKE ) build-static TARGETPLATFORM=windows/$*
43+
44+ .PHONY : build-static
45+ build-static :
46+ PRODUCT=" $( PRODUCT) " \
47+ PLATFORM=" $( PLATFORM) " \
48+ DEFAULT_PRODUCT_LICENSE=" $( DEFAULT_PRODUCT_LICENSE) " \
49+ PACKAGER_NAME=" $( PACKAGER_NAME) " \
50+ CLI_DIR=" $( CLI_DIR) " \
51+ ENGINE_DIR=" $( ENGINE_DIR) " \
52+ BUILDX_DIR=" $( BUILDX_DIR) " \
53+ STATIC_VER=" $( GEN_STATIC_VER) " \
54+ DOCKER_BUILDX_REF=" $( DOCKER_BUILDX_REF) " \
55+ CONTAINERD_VERSION=" $( CONTAINERD_VERSION) " \
56+ RUNC_VERSION=" $( RUNC_VERSION) " \
57+ ./build-static " $( CURDIR) " " $( TARGETPLATFORM) "
6458
6559.PHONY : hash_files
6660hash_files :
6761 @echo " Hashing directory $( DIR_TO_HASH) "
6862 $(HASH_CMD ) " $( DIR_TO_HASH) "
69-
70- .PHONY : buildx
71- buildx :
72- docker buildx inspect | grep -q ' Driver: docker-container' || docker buildx create --use
73-
74- .PHONY : cross-mac
75- cross-mac : buildx
76- cd $(CLI_DIR ) && VERSION=$(GEN_STATIC_VER ) docker buildx bake --set binary.platform=darwin/amd64,darwin/arm64 binary
77- dest=$$ PWD/build/mac; cd $(CLI_DIR ) /build && for platform in * ; do \
78- arch=$$(echo $$platform | cut -d_ -f2 ) ; \
79- mkdir -p $$ dest/$$ arch/docker; \
80- cp $$ platform/docker-darwin-* $$ dest/$$ arch/docker/docker && \
81- tar -C $$ dest/$$ arch -c -z -f $$ dest/$$ arch/docker-$(GEN_STATIC_VER ) .tgz docker; \
82- done
83-
84- .PHONY : cross-win
85- cross-win : cross-win-engine
86- cd $(CLI_DIR ) && VERSION=$(GEN_STATIC_VER ) docker buildx bake --set binary.platform=windows/amd64 binary
87- mkdir -p build/win/amd64/docker
88- cp $(CLI_DIR ) /build/docker-windows-amd64.exe build/win/amd64/docker/docker.exe
89- cp $(ENGINE_DIR ) /bundles/cross/windows/amd64-daemon/dockerd-$(GEN_STATIC_VER ) .exe build/win/amd64/docker/dockerd.exe
90- cp $(ENGINE_DIR ) /bundles/cross/windows/amd64-daemon/docker-proxy-$(GEN_STATIC_VER ) .exe build/win/amd64/docker/docker-proxy.exe
91- docker run --rm -v $(CURDIR ) /build/win/amd64:/v -w /v alpine sh -c ' apk update&&apk add zip&&zip -r docker-$(GEN_STATIC_VER).zip docker'
92- $(CHOWN ) -R $(shell id -u) :$(shell id -g) build
93-
94- .PHONY : cross-arm
95- cross-arm : cross-all-cli # # create tgz with linux armhf client only
96- mkdir -p build/arm/docker
97- cp $(CLI_DIR ) /build/docker-linux-arm build/arm/docker/docker
98- tar -C build/arm -c -z -f build/arm/docker-$(GEN_STATIC_VER ) .tgz docker
99-
100- .PHONY : static-cli
101- static-cli :
102- cd $(CLI_DIR ) && VERSION=$(GEN_STATIC_VER ) docker buildx bake --set binary.platform=$(TARGETPLATFORM ) --set binary.args.CGO_ENABLED=$(CGO_ENABLED ) binary
103-
104- .PHONY : static-engine
105- static-engine :
106- $(MAKE ) -C $(ENGINE_DIR ) VERSION=$(GEN_STATIC_VER ) DOCKER_BUILD_OPTS=" $( DOCKER_BUILD_OPTS) " binary
107-
108- .PHONY : static-buildx-plugin
109- static-buildx-plugin :
110- cd $(BUILDX_DIR ) && docker buildx bake --set binaries.platform=$(TARGETPLATFORM ) binaries && mv ./bin/buildx ./bin/docker-buildx
111-
112- .PHONY : cross-all-cli
113- cross-all-cli :
114- $(MAKE ) -C $(CLI_DIR ) -f docker.Makefile VERSION=$(GEN_STATIC_VER ) cross
115-
116- .PHONY : cross-win-engine
117- cross-win-engine :
118- $(MAKE ) -C $(ENGINE_DIR ) VERSION=$(GEN_STATIC_VER ) DOCKER_CROSSPLATFORMS=windows/amd64 DOCKER_BUILD_OPTS=" $( DOCKER_BUILD_OPTS) " cross
0 commit comments