Skip to content

Commit f0188d6

Browse files
authored
Merge pull request #654 from crazy-max/buildx-package
[master] add docker-buildx-plugin package (deb, rpm, static)
2 parents de92dc5 + 4f48724 commit f0188d6

File tree

20 files changed

+132
-214
lines changed

20 files changed

+132
-214
lines changed

Makefile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ clean-src:
1515
$(RM) -r src
1616

1717
.PHONY: src
18-
src: src/github.com/docker/cli src/github.com/docker/docker src/github.com/docker/compose src/github.com/docker/scan-cli-plugin ## clone source
18+
src: src/github.com/docker/cli src/github.com/docker/docker src/github.com/docker/buildx src/github.com/docker/compose src/github.com/docker/scan-cli-plugin ## clone source
1919

2020
ifdef CLI_DIR
2121
src/github.com/docker/cli:
@@ -37,6 +37,10 @@ src/github.com/docker/docker:
3737
git -C $@ remote add origin "$(DOCKER_ENGINE_REPO)"
3838
endif
3939

40+
src/github.com/docker/buildx:
41+
git init $@
42+
git -C $@ remote add origin "$(DOCKER_BUILDX_REPO)"
43+
4044
src/github.com/docker/compose:
4145
git init $@
4246
git -C $@ remote add origin "$(DOCKER_COMPOSE_REPO)"
@@ -54,6 +58,10 @@ checkout-cli: src/github.com/docker/cli
5458
checkout-docker: src/github.com/docker/docker
5559
./scripts/checkout.sh src/github.com/docker/docker "$(DOCKER_ENGINE_REF)"
5660

61+
.PHONY: checkout-buildx
62+
checkout-buildx: src/github.com/docker/buildx
63+
./scripts/checkout.sh src/github.com/docker/buildx "$(DOCKER_BUILDX_REF)"
64+
5765
.PHONY: checkout-compose
5866
checkout-compose: src/github.com/docker/compose
5967
./scripts/checkout.sh src/github.com/docker/compose "$(DOCKER_COMPOSE_REF)"
@@ -63,7 +71,7 @@ checkout-scan-cli-plugin: src/github.com/docker/scan-cli-plugin
6371
./scripts/checkout.sh src/github.com/docker/scan-cli-plugin "$(DOCKER_SCAN_REF)"
6472

6573
.PHONY: checkout
66-
checkout: checkout-cli checkout-docker checkout-compose checkout-scan-cli-plugin ## checkout source at the given reference(s)
74+
checkout: checkout-cli checkout-docker checkout-buildx checkout-compose checkout-scan-cli-plugin ## checkout source at the given reference(s)
6775

6876
.PHONY: clean
6977
clean: clean-src ## remove build artifacts

common.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ DOCKER_CLI_REPO ?= https://github.com/docker/cli.git
2828
DOCKER_ENGINE_REPO ?= https://github.com/docker/docker.git
2929
DOCKER_SCAN_REPO ?= https://github.com/docker/scan-cli-plugin.git
3030
DOCKER_COMPOSE_REPO ?= https://github.com/docker/compose.git
31+
DOCKER_BUILDX_REPO ?= https://github.com/docker/buildx.git
3132

3233
# REF can be used to specify the same branch or tag to use for *both* the CLI
3334
# and Engine source code. This can be useful if both the CLI and Engine have a
@@ -40,6 +41,7 @@ DOCKER_CLI_REF ?= $(REF)
4041
DOCKER_ENGINE_REF ?= $(REF)
4142
DOCKER_SCAN_REF ?= v0.17.0
4243
DOCKER_COMPOSE_REF ?= v2.3.4
44+
DOCKER_BUILDX_REF ?= v0.8.1
4345

4446
export BUILDTIME
4547
export DEFAULT_PRODUCT_LICENSE

deb/Makefile

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ RUN?=docker run --rm \
3333
-e VERSION=$(word 2, $(GEN_DEB_VER)) \
3434
-e CLI_GITCOMMIT=$(CLI_GITCOMMIT) \
3535
-e ENGINE_GITCOMMIT=$(ENGINE_GITCOMMIT) \
36+
-e BUILDX_VERSION=$(DOCKER_BUILDX_REF) \
3637
-e COMPOSE_VERSION=$(DOCKER_COMPOSE_REF) \
3738
-e SCAN_VERSION=$(DOCKER_SCAN_REF) \
3839
-e SCAN_GITCOMMIT=$(SCAN_GITCOMMIT) \
@@ -78,7 +79,7 @@ $(DISTROS): sources
7879
$(CHOWN) -R $(shell id -u):$(shell id -g) "debbuild/$@"
7980

8081
.PHONY: sources
81-
sources: sources/cli.tgz sources/engine.tgz sources/compose.tgz sources/scan-cli-plugin.tgz sources/plugin-installers.tgz
82+
sources: sources/cli.tgz sources/engine.tgz sources/buildx.tgz sources/compose.tgz sources/scan-cli-plugin.tgz
8283

8384
sources/engine.tgz:
8485
mkdir -p $(@D)
@@ -96,6 +97,14 @@ sources/cli.tgz:
9697
alpine \
9798
tar -C / -c -z -f /v/cli.tgz --exclude .git cli
9899

100+
sources/buildx.tgz:
101+
mkdir -p $(@D)
102+
docker run --rm -w /v \
103+
-v $(realpath $(CURDIR)/../src/github.com/docker/buildx):/buildx \
104+
-v $(CURDIR)/$(@D):/v \
105+
alpine \
106+
tar -C / -c -z -f /v/buildx.tgz --exclude .git buildx
107+
99108
sources/compose.tgz:
100109
mkdir -p $(@D)
101110
docker run --rm -w /v \
@@ -112,13 +121,6 @@ sources/scan-cli-plugin.tgz:
112121
alpine \
113122
tar -C / -c -z -f /v/scan-cli-plugin.tgz --exclude .git scan-cli-plugin
114123

115-
sources/plugin-installers.tgz: $(wildcard ../plugins/*)
116-
docker run --rm -w /v \
117-
-v $(PLUGINS_DIR):/plugins \
118-
-v $(CURDIR)/$(@D):/v \
119-
alpine \
120-
tar -C / -c -z -f /v/plugin-installers.tgz --exclude .git plugins
121-
122124
# See ARCHES in common.mk. Could not figure out how to match both distro and arch.
123125
BUNDLES:=$(addsuffix .tar.gz,$(addprefix debbuild/bundles-ce-%-,$(ARCHES)))
124126

deb/build-deb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ mkdir -p /root/build-deb/engine
77
tar -C /root/build-deb -xzf /sources/engine.tgz
88
mkdir -p /root/build-deb/cli
99
tar -C /root/build-deb -xzf /sources/cli.tgz
10+
mkdir -p /root/build-deb/buildx
11+
tar -C /root/build-deb -xzf /sources/buildx.tgz
1012
mkdir -p /root/build-deb/compose
1113
tar -C /root/build-deb -xzf /sources/compose.tgz
1214
mkdir -p /root/build-deb/scan-cli-plugin
@@ -16,6 +18,7 @@ tar -C /root/build-deb -xzf /sources/scan-cli-plugin.tgz
1618
mkdir -p /go/src/github.com/docker
1719
ln -snf /root/build-deb/engine /go/src/github.com/docker/docker
1820
ln -snf /root/build-deb/cli /go/src/github.com/docker/cli
21+
ln -snf /root/build-deb/buildx /go/src/github.com/docker/buildx
1922
ln -snf /root/build-deb/compose /go/src/github.com/docker/compose
2023
ln -snf /root/build-deb/scan-cli-plugin /go/src/github.com/docker/scan-cli-plugin
2124

deb/common/control

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ Package: docker-ce-cli
6363
Architecture: linux-any
6464
Depends: ${shlibs:Depends}
6565
# TODO change once we support scan-plugin on other architectures
66-
Recommends: docker-compose-plugin,
66+
Recommends: docker-buildx-plugin,
67+
docker-compose-plugin,
6768
docker-scan-plugin [amd64]
6869
Conflicts: docker (<< 1.5~),
6970
docker-engine,
@@ -103,6 +104,14 @@ Description: Rootless support for Docker.
103104
Either VPNKit or slirp4netns (>= 0.4.0) needs to be installed separately.
104105
Homepage: https://docs.docker.com/engine/security/rootless/
105106

107+
Package: docker-buildx-plugin
108+
Priority: optional
109+
Replaces: docker-ce-cli
110+
Architecture: linux-any
111+
Enhances: docker-ce-cli
112+
Description: Docker Buildx cli plugin.
113+
Homepage: https://github.com/docker/buildx
114+
106115
Package: docker-compose-plugin
107116
Priority: optional
108117
Architecture: linux-any

deb/common/rules

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ override_dh_auto_build:
1616
# Build the CLI
1717
cd /go/src/github.com/docker/cli && VERSION=$(VERSION) GITCOMMIT=$(CLI_GITCOMMIT) LDFLAGS='' GO_LINKMODE=dynamic ./scripts/build/binary && DISABLE_WARN_OUTSIDE_CONTAINER=1 LDFLAGS='' make manpages
1818

19+
# Build buildx plugin
20+
cd /go/src/github.com/docker/buildx \
21+
&& mkdir -p /usr/libexec/docker/cli-plugins/ \
22+
&& CGO_ENABLED=0 GO111MODULE=on go build -mod=vendor -o /usr/libexec/docker/cli-plugins/docker-buildx -ldflags "-X github.com/docker/buildx/version.Version=$(BUILDX_VERSION) -X github.com/docker/buildx/version.Revision=$(git rev-parse HEAD) -X github.com/docker/buildx/version.Package=github.com/docker/buildx" ./cmd/buildx
23+
1924
# Build the compose plugin
2025
# FIXME: using GOPROXY, to work around:
2126
# go: github.com/Azure/[email protected]+incompatible: reading github.com/Azure/azure-sdk-for-go/go.mod at revision v48.2.0: unknown revision v48.2.0
@@ -34,21 +39,16 @@ override_dh_auto_build:
3439
&& mv bin/docker-scan /usr/libexec/docker/cli-plugins/; \
3540
fi
3641

37-
# Build the CLI plugins
38-
# Make sure to set LDFLAGS="" since, dpkg-buildflags sets it to some weird values
39-
set -e;cd /sources && \
40-
tar xzf plugin-installers.tgz; \
41-
for installer in plugins/*.installer; do \
42-
LDFLAGS='' bash $${installer} build; \
43-
done
44-
4542
override_dh_auto_test:
4643
ver="$$(engine/bundles/dynbinary-daemon/dockerd --version)"; \
4744
test "$$ver" = "Docker version $(VERSION), build $(ENGINE_GITCOMMIT)" && echo "PASS: daemon version OK" || (echo "FAIL: daemon version ($$ver) did not match" && exit 1)
4845

4946
ver="$$(cli/build/docker --version)"; \
5047
test "$$ver" = "Docker version $(VERSION), build $(CLI_GITCOMMIT)" && echo "PASS: cli version OK" || (echo "FAIL: cli version ($$ver) did not match" && exit 1)
5148

49+
ver="$$(/usr/libexec/docker/cli-plugins/docker-buildx docker-cli-plugin-metadata | awk '{ gsub(/[",:]/,"")}; $$1 == "Version" { print $$2 }')"; \
50+
test "$$ver" = "$(BUILDX_VERSION)" && echo "PASS: docker-buildx version OK" || (echo "FAIL: docker-buildx version ($$ver) did not match" && exit 1)
51+
5252
ver="$$(/usr/libexec/docker/cli-plugins/docker-compose docker-cli-plugin-metadata | awk '{ gsub(/[",:]/,"")}; $$1 == "Version" { print $$2 }')"; \
5353
test "$$ver" = "$(COMPOSE_VERSION)" && echo "PASS: docker-compose version OK" || (echo "FAIL: docker-compose version ($$ver) did not match" && exit 1)
5454

@@ -67,20 +67,17 @@ override_dh_auto_install:
6767
install -D -m 0644 cli/contrib/completion/fish/docker.fish debian/docker-ce-cli/usr/share/fish/vendor_completions.d/docker.fish
6868
install -D -m 0644 cli/contrib/completion/zsh/_docker debian/docker-ce-cli/usr/share/zsh/vendor-completions/_docker
6969
install -D -m 0755 cli/build/docker debian/docker-ce-cli/usr/bin/docker
70-
set -e;cd /sources && \
71-
tar xzf plugin-installers.tgz; \
72-
for installer in plugins/*.installer; do \
73-
DESTDIR=/root/build-deb/debian/docker-ce-cli \
74-
PREFIX=/usr/libexec/docker/cli-plugins \
75-
bash $${installer} install_plugin; \
76-
done
70+
7771
# docker-ce install
7872
install -D -m 0644 engine/contrib/init/systemd/docker.service debian/docker-ce/lib/systemd/system/docker.service
7973
install -D -m 0644 engine/contrib/init/systemd/docker.socket debian/docker-ce/lib/systemd/system/docker.socket
8074
install -D -m 0755 $(shell readlink -e engine/bundles/dynbinary-daemon/dockerd) debian/docker-ce/usr/bin/dockerd
8175
install -D -m 0755 $(shell readlink -e engine/bundles/dynbinary-daemon/docker-proxy) debian/docker-ce/usr/bin/docker-proxy
8276
install -D -m 0755 /usr/local/bin/docker-init debian/docker-ce/usr/bin/docker-init
8377

78+
# docker-buildx-plugin install
79+
install -D -m 0755 /usr/libexec/docker/cli-plugins/docker-buildx debian/docker-buildx-plugin/usr/libexec/docker/cli-plugins/docker-buildx
80+
8481
# docker-compose-plugin install
8582
install -D -m 0755 /usr/libexec/docker/cli-plugins/docker-compose debian/docker-compose-plugin/usr/libexec/docker/cli-plugins/docker-compose
8683

@@ -110,6 +107,10 @@ override_dh_install:
110107
dh_apparmor --profile-name=docker-ce -pdocker-ce
111108

112109
override_dh_gencontrol:
110+
# Use separate version for the buildx-plugin package, then generate the other control files as usual
111+
# TODO override "Source" field in control as well (to point to buildx, as it doesn't match the package name)
112+
dh_gencontrol -pdocker-buildx-plugin -- -v$${BUILDX_VERSION#v}~$${DISTRO}-$${SUITE}
113+
113114
# Use separate version for the compose-plugin package, then generate the other control files as usual
114115
# TODO override "Source" field in control as well (to point to compose, as it doesn't match the package name)
115116
dh_gencontrol -pdocker-compose-plugin -- -v$${COMPOSE_VERSION#v}~$${DISTRO}-$${SUITE}

plugins/.common

Lines changed: 0 additions & 37 deletions
This file was deleted.

plugins/buildx.installer

Lines changed: 0 additions & 34 deletions
This file was deleted.

plugins/scan.installer.disabled

Lines changed: 0 additions & 40 deletions
This file was deleted.

rpm/Makefile

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ PLUGINS_DIR=$(realpath $(CURDIR)/../plugins)
44
GO_BASE_IMAGE=golang
55
GO_IMAGE?=$(GO_BASE_IMAGE):$(GO_VERSION)-buster
66
GEN_RPM_VER=$(shell ./gen-rpm-ver $(realpath $(CURDIR)/../src/github.com/docker/cli) "$(VERSION)")
7+
GEN_BUILDX_RPM_VER=$(shell ./gen-rpm-ver $(realpath $(CURDIR)/../src/github.com/docker/buildx) "$(DOCKER_BUILDX_REF)")
78
GEN_COMPOSE_RPM_VER=$(shell ./gen-rpm-ver $(realpath $(CURDIR)/../src/github.com/docker/compose) "$(DOCKER_COMPOSE_REF)")
89
GEN_SCAN_RPM_VER=$(shell ./gen-rpm-ver $(realpath $(CURDIR)/../src/github.com/docker/scan-cli-plugin) "$(DOCKER_SCAN_REF)")
910
CLI_GITCOMMIT?=$(shell cd $(realpath $(CURDIR)/../src/github.com/docker/cli) && git rev-parse --short HEAD)
@@ -23,9 +24,9 @@ BUILD?=DOCKER_BUILDKIT=1 \
2324

2425

2526
ifeq ($(ARCH),x86_64)
26-
SPEC_FILES?=docker-ce.spec docker-ce-cli.spec docker-ce-rootless-extras.spec docker-compose-plugin.spec docker-scan-plugin.spec
27+
SPEC_FILES?=docker-ce.spec docker-ce-cli.spec docker-ce-rootless-extras.spec docker-buildx-plugin.spec docker-compose-plugin.spec docker-scan-plugin.spec
2728
else
28-
SPEC_FILES?=docker-ce.spec docker-ce-cli.spec docker-ce-rootless-extras.spec docker-compose-plugin.spec
29+
SPEC_FILES?=docker-ce.spec docker-ce-cli.spec docker-ce-rootless-extras.spec docker-buildx-plugin.spec docker-compose-plugin.spec
2930
endif
3031

3132
SPECS?=$(addprefix SPECS/, $(SPEC_FILES))
@@ -35,6 +36,8 @@ RPMBUILD_FLAGS?=-ba\
3536
--define '_release $(word 2,$(GEN_RPM_VER))' \
3637
--define '_version $(word 1,$(GEN_RPM_VER))' \
3738
--define '_origversion $(word 4, $(GEN_RPM_VER))' \
39+
--define '_buildx_rpm_version $(word 1,$(GEN_BUILDX_RPM_VER))' \
40+
--define '_buildx_version $(word 4,$(GEN_BUILDX_RPM_VER))' \
3841
--define '_compose_rpm_version $(word 1,$(GEN_COMPOSE_RPM_VER))' \
3942
--define '_compose_version $(word 4,$(GEN_COMPOSE_RPM_VER))' \
4043
--define '_scan_rpm_version $(word 1,$(GEN_SCAN_RPM_VER))' \
@@ -98,7 +101,7 @@ $(DISTROS): sources
98101
$(CHOWN) -R $(shell id -u):$(shell id -g) "rpmbuild/$@"
99102

100103
.PHONY: sources
101-
sources: rpmbuild/SOURCES/engine.tgz rpmbuild/SOURCES/cli.tgz rpmbuild/SOURCES/compose.tgz rpmbuild/SOURCES/scan-cli-plugin.tgz rpmbuild/SOURCES/plugin-installers.tgz
104+
sources: rpmbuild/SOURCES/engine.tgz rpmbuild/SOURCES/cli.tgz rpmbuild/SOURCES/buildx.tgz rpmbuild/SOURCES/compose.tgz rpmbuild/SOURCES/scan-cli-plugin.tgz
102105

103106
rpmbuild/SOURCES/engine.tgz:
104107
mkdir -p $(@D)
@@ -116,6 +119,14 @@ rpmbuild/SOURCES/cli.tgz:
116119
alpine \
117120
tar -C / -c -z -f /v/cli.tgz --exclude .git cli
118121

122+
rpmbuild/SOURCES/buildx.tgz:
123+
mkdir -p $(@D)
124+
docker run --rm -w /v \
125+
-v $(realpath $(CURDIR)/../src/github.com/docker/buildx):/buildx \
126+
-v $(CURDIR)/$(@D):/v \
127+
alpine \
128+
tar -C / -c -z -f /v/buildx.tgz --exclude .git buildx
129+
119130
rpmbuild/SOURCES/compose.tgz:
120131
mkdir -p $(@D)
121132
docker run --rm -w /v \
@@ -132,13 +143,6 @@ rpmbuild/SOURCES/scan-cli-plugin.tgz:
132143
alpine \
133144
tar -C / -c -z -f /v/scan-cli-plugin.tgz --exclude .git scan-cli-plugin
134145

135-
rpmbuild/SOURCES/plugin-installers.tgz: $(wildcard ../plugins/*)
136-
docker run --rm -w /v \
137-
-v $(PLUGINS_DIR):/plugins \
138-
-v $(CURDIR)/$(@D):/v \
139-
alpine \
140-
tar -C / -c -z -f /v/plugin-installers.tgz --exclude .git plugins
141-
142146
# See ARCHES in common.mk. Could not figure out how to match both distro and arch.
143147
BUNDLES:=$(addsuffix .tar.gz,$(addprefix rpmbuild/bundles-ce-%-,$(ARCHES)))
144148

0 commit comments

Comments
 (0)