@@ -4,115 +4,32 @@ CLI_DIR=$(realpath $(CURDIR)/../src/github.com/docker/cli)
4
4
ENGINE_DIR =$(realpath $(CURDIR ) /../src/github.com/docker/docker)
5
5
BUILDX_DIR =$(realpath $(CURDIR ) /../src/github.com/docker/buildx)
6
6
7
- GEN_STATIC_VER =$(shell ./gen-static-ver $(CLI_DIR ) $(VERSION ) )
7
+ STATIC_VERSION =$(shell ./gen-static-ver $(CLI_DIR ) $(VERSION ) )
8
8
HASH_CMD =docker run -v $(CURDIR ) :/sum -w /sum debian:jessie bash hash_files
9
9
DIR_TO_HASH: =build/linux
10
- DOCKER_CLI_GOLANG_IMG =golang:$(GO_VERSION )
11
10
12
- DOCKER_BUILD_OPTS =
11
+ export CLI_DIR
12
+ export ENGINE_DIR
13
+ export BUILDX_DIR
13
14
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
15
+ export STATIC_VERSION
16
+ export CONTAINERD_VERSION
17
+ export RUNC_VERSION
30
18
31
19
.PHONY : help
32
- help : # # show make targets
33
- @awk ' BEGIN {FS = ":.*?## "} / ^[a-zA-Z_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2); printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}' $( MAKEFILE_LIST )
20
+ help :
21
+ @grep -E ' ^[a-zA-Z_-]+:.*?## .*$$ ' $( MAKEFILE_LIST ) | sort | awk ' BEGIN {FS = ":.*?## "}; { printf "$(BOLD)$(CYAN)%-25s$(RESET) %s\n", $$1, $$2}'
34
22
35
23
.PHONY : clean
36
24
clean : # # remove build artifacts
37
- [ ! -d build ] || $(CHOWN ) -R $(shell id -u) :$(shell id -g) build
38
- $(RM ) -r build
39
- -docker builder prune -f --filter until=24h
40
-
41
- .PHONY : static
42
- static : static-linux cross-mac cross-win cross-arm # # create all static packages
43
-
44
- .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
25
+ @[ ! -d build ] || $(CHOWN ) -R $(shell id -u) :$(shell id -g) build
26
+ @$(RM ) -r build
61
27
62
- # buildx
63
- tar -C $(BUILDX_DIR)/bin -c -z -f build/linux/docker-buildx-plugin-$(DOCKER_BUILDX_REF:v%=%).tgz docker-buildx
28
+ .PHONY : build
29
+ build : # # build static package
30
+ ./build-static " $( CURDIR) " " $( TARGETPLATFORM) "
64
31
65
32
.PHONY : hash_files
66
- hash_files :
33
+ hash_files : # # hash files
67
34
@echo " Hashing directory $( DIR_TO_HASH) "
68
35
$(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