Skip to content

Commit 37aa0a7

Browse files
committed
add docker-buildx-plugin package (deb, rpm)
Signed-off-by: CrazyMax <[email protected]>
1 parent de92dc5 commit 37aa0a7

File tree

16 files changed

+118
-8
lines changed

16 files changed

+118
-8
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 & 1 deletion
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 sources/plugin-installers.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 \

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: 15 additions & 0 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
@@ -49,6 +54,9 @@ override_dh_auto_test:
4954
ver="$$(cli/build/docker --version)"; \
5055
test "$$ver" = "Docker version $(VERSION), build $(CLI_GITCOMMIT)" && echo "PASS: cli version OK" || (echo "FAIL: cli version ($$ver) did not match" && exit 1)
5156

57+
ver="$$(/usr/libexec/docker/cli-plugins/docker-buildx docker-cli-plugin-metadata | awk '{ gsub(/[",:]/,"")}; $$1 == "Version" { print $$2 }')"; \
58+
test "$$ver" = "$(BUILDX_VERSION)" && echo "PASS: docker-buildx version OK" || (echo "FAIL: docker-buildx version ($$ver) did not match" && exit 1)
59+
5260
ver="$$(/usr/libexec/docker/cli-plugins/docker-compose docker-cli-plugin-metadata | awk '{ gsub(/[",:]/,"")}; $$1 == "Version" { print $$2 }')"; \
5361
test "$$ver" = "$(COMPOSE_VERSION)" && echo "PASS: docker-compose version OK" || (echo "FAIL: docker-compose version ($$ver) did not match" && exit 1)
5462

@@ -81,6 +89,9 @@ override_dh_auto_install:
8189
install -D -m 0755 $(shell readlink -e engine/bundles/dynbinary-daemon/docker-proxy) debian/docker-ce/usr/bin/docker-proxy
8290
install -D -m 0755 /usr/local/bin/docker-init debian/docker-ce/usr/bin/docker-init
8391

92+
# docker-buildx-plugin install
93+
install -D -m 0755 /usr/libexec/docker/cli-plugins/docker-buildx debian/docker-buildx-plugin/usr/libexec/docker/cli-plugins/docker-buildx
94+
8495
# docker-compose-plugin install
8596
install -D -m 0755 /usr/libexec/docker/cli-plugins/docker-compose debian/docker-compose-plugin/usr/libexec/docker/cli-plugins/docker-compose
8697

@@ -110,6 +121,10 @@ override_dh_install:
110121
dh_apparmor --profile-name=docker-ce -pdocker-ce
111122

112123
override_dh_gencontrol:
124+
# Use separate version for the buildx-plugin package, then generate the other control files as usual
125+
# TODO override "Source" field in control as well (to point to buildx, as it doesn't match the package name)
126+
dh_gencontrol -pdocker-buildx-plugin -- -v$${BUILDX_VERSION#v}~$${DISTRO}-$${SUITE}
127+
113128
# Use separate version for the compose-plugin package, then generate the other control files as usual
114129
# TODO override "Source" field in control as well (to point to compose, as it doesn't match the package name)
115130
dh_gencontrol -pdocker-compose-plugin -- -v$${COMPOSE_VERSION#v}~$${DISTRO}-$${SUITE}
File renamed without changes.

rpm/Makefile

Lines changed: 14 additions & 3 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 rpmbuild/SOURCES/plugin-installers.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 \

rpm/SPECS/docker-buildx-plugin.spec

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
%global debug_package %{nil}
2+
3+
Name: docker-buildx-plugin
4+
Version: %{_buildx_rpm_version}
5+
Release: %{_release}%{?dist}
6+
Epoch: 0
7+
Source0: buildx.tgz
8+
Summary: Docker Buildx plugin for the Docker CLI
9+
Group: Tools/Docker
10+
License: ASL 2.0
11+
URL: https://github.com/docker/buildx
12+
Vendor: Docker
13+
Packager: Docker <[email protected]>
14+
15+
BuildRequires: bash
16+
17+
%description
18+
Docker Buildx plugin for the Docker CLI.
19+
20+
%prep
21+
%setup -q -c -n src -a 0
22+
23+
%build
24+
pushd ${RPM_BUILD_DIR}/src/buildx
25+
bash -c 'CGO_ENABLED=0 GO111MODULE=on go build -mod=vendor -o bin/docker-buildx -ldflags "-X github.com/docker/buildx/version.Version=%{_buildx_version} -X github.com/docker/buildx/version.Revision=%{_buildx_gitcommit} -X github.com/docker/buildx/version.Package=github.com/docker/buildx" ./cmd/buildx'
26+
popd
27+
28+
%check
29+
ver="$(${RPM_BUILD_ROOT}%{_libexecdir}/docker/cli-plugins/docker-buildx docker-cli-plugin-metadata | awk '{ gsub(/[",:]/,"")}; $1 == "Version" { print $2 }')"; \
30+
test "$ver" = "%{_buildx_version}" && echo "PASS: docker-buildx version OK" || (echo "FAIL: docker-buildx version ($ver) did not match" && exit 1)
31+
32+
%install
33+
pushd ${RPM_BUILD_DIR}/src/buildx
34+
install -D -p -m 0755 bin/docker-buildx ${RPM_BUILD_ROOT}%{_libexecdir}/docker/cli-plugins/docker-buildx
35+
popd
36+
37+
%files
38+
%{_libexecdir}/docker/cli-plugins/docker-buildx
39+
40+
%post
41+
42+
%preun
43+
44+
%postun
45+
46+
%changelog

rpm/SPECS/docker-ce-cli.spec

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ Requires: /usr/sbin/groupadd
2222
# Note that we're not using <= 7 here, to account for other RPM distros, such
2323
# as Fedora, which would not have the rhel macro set (so default to 0).
2424
%if 0%{?rhel} == 7
25+
Requires: docker-buildx-plugin
2526
Requires: docker-compose-plugin
2627
%else
28+
Recommends: docker-buildx-plugin
2729
Recommends: docker-compose-plugin
2830
%endif
2931

@@ -128,7 +130,6 @@ done
128130
%files
129131
%doc build-docs/LICENSE build-docs/MAINTAINERS build-docs/NOTICE build-docs/README.md
130132
%{_bindir}/docker
131-
%{_libexecdir}/docker/cli-plugins/*
132133
%{_datadir}/bash-completion/completions/docker
133134
%{_datadir}/zsh/vendor-completions/_docker
134135
%{_datadir}/fish/vendor_completions.d/docker.fish

0 commit comments

Comments
 (0)