Skip to content

Commit 71099ea

Browse files
authored
Merge pull request #553 from thaJeztah/add_compose_cli_package
[master] add docker-compose-plugin package (deb, rpm)
2 parents a95571d + cab7b56 commit 71099ea

File tree

8 files changed

+138
-9
lines changed

8 files changed

+138
-9
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/scan-cli-plugin ## clone source
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
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/compose:
41+
git init $@
42+
git -C $@ remote add origin "$(DOCKER_COMPOSE_REPO)"
43+
4044
src/github.com/docker/scan-cli-plugin:
4145
git init $@
4246
git -C $@ remote add origin "$(DOCKER_SCAN_REPO)"
@@ -50,12 +54,16 @@ checkout-cli: src/github.com/docker/cli
5054
checkout-docker: src/github.com/docker/docker
5155
./scripts/checkout.sh src/github.com/docker/docker "$(DOCKER_ENGINE_REF)"
5256

57+
.PHONY: checkout-compose
58+
checkout-compose: src/github.com/docker/compose
59+
./scripts/checkout.sh src/github.com/docker/compose "$(DOCKER_COMPOSE_REF)"
60+
5361
.PHONY: checkout-scan-cli-plugin
5462
checkout-scan-cli-plugin: src/github.com/docker/scan-cli-plugin
5563
./scripts/checkout.sh src/github.com/docker/scan-cli-plugin "$(DOCKER_SCAN_REF)"
5664

5765
.PHONY: checkout
58-
checkout: checkout-cli checkout-docker checkout-scan-cli-plugin ## checkout source at the given reference(s)
66+
checkout: checkout-cli checkout-docker checkout-compose checkout-scan-cli-plugin ## checkout source at the given reference(s)
5967

6068
.PHONY: clean
6169
clean: clean-src ## remove build artifacts

common.mk

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ VERSION?=0.0.1-dev
2323

2424
# DOCKER_CLI_REPO and DOCKER_ENGINE_REPO define the source repositories to clone
2525
# the source from. These can be overridden to build from a fork.
26-
DOCKER_CLI_REPO ?= https://github.com/docker/cli.git
27-
DOCKER_ENGINE_REPO ?= https://github.com/docker/docker.git
28-
DOCKER_SCAN_REPO ?= https://github.com/docker/scan-cli-plugin.git
26+
DOCKER_CLI_REPO ?= https://github.com/docker/cli.git
27+
DOCKER_ENGINE_REPO ?= https://github.com/docker/docker.git
28+
DOCKER_SCAN_REPO ?= https://github.com/docker/scan-cli-plugin.git
29+
DOCKER_COMPOSE_REPO ?= https://github.com/docker/compose.git
2930

3031
# REF can be used to specify the same branch or tag to use for *both* the CLI
3132
# and Engine source code. This can be useful if both the CLI and Engine have a
@@ -37,6 +38,7 @@ REF ?= HEAD
3738
DOCKER_CLI_REF ?= $(REF)
3839
DOCKER_ENGINE_REF ?= $(REF)
3940
DOCKER_SCAN_REF ?= v0.17.0
41+
DOCKER_COMPOSE_REF ?= v2.3.1
4042

4143
export BUILDTIME
4244
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 COMPOSE_VERSION=$(DOCKER_COMPOSE_REF) \
3637
-e SCAN_VERSION=$(DOCKER_SCAN_REF) \
3738
-e SCAN_GITCOMMIT=$(SCAN_GITCOMMIT) \
3839
-v $(CURDIR)/debbuild/$@:/build \
@@ -77,7 +78,7 @@ $(DISTROS): sources
7778
$(CHOWN) -R $(shell id -u):$(shell id -g) "debbuild/$@"
7879

7980
.PHONY: sources
80-
sources: sources/cli.tgz sources/engine.tgz sources/scan-cli-plugin.tgz sources/plugin-installers.tgz
81+
sources: sources/cli.tgz sources/engine.tgz sources/compose.tgz sources/scan-cli-plugin.tgz sources/plugin-installers.tgz
8182

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

99+
sources/compose.tgz:
100+
mkdir -p $(@D)
101+
docker run --rm -w /v \
102+
-v $(realpath $(CURDIR)/../src/github.com/docker/compose):/compose \
103+
-v $(CURDIR)/$(@D):/v \
104+
alpine \
105+
tar -C / -c -z -f /v/compose.tgz --exclude .git compose
106+
98107
sources/scan-cli-plugin.tgz:
99108
mkdir -p $(@D)
100109
docker run --rm -w /v \

deb/build-deb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@ 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/compose
11+
tar -C /root/build-deb -xzf /sources/compose.tgz
1012
mkdir -p /root/build-deb/scan-cli-plugin
1113
tar -C /root/build-deb -xzf /sources/scan-cli-plugin.tgz
1214

1315
# link them to their canonical path
1416
mkdir -p /go/src/github.com/docker
1517
ln -snf /root/build-deb/engine /go/src/github.com/docker/docker
1618
ln -snf /root/build-deb/cli /go/src/github.com/docker/cli
19+
ln -snf /root/build-deb/compose /go/src/github.com/docker/compose
1720
ln -snf /root/build-deb/scan-cli-plugin /go/src/github.com/docker/scan-cli-plugin
1821

1922
EPOCH="${EPOCH:-}"

deb/common/control

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,18 @@ Description: Rootless support for Docker.
102102
Either VPNKit or slirp4netns (>= 0.4.0) needs to be installed separately.
103103
Homepage: https://docs.docker.com/engine/security/rootless/
104104

105+
Package: docker-compose-plugin
106+
Priority: optional
107+
Architecture: linux-any
108+
Enhances: docker-ce-cli
109+
Description: Docker Compose (V2) plugin for the Docker CLI.
110+
.
111+
This plugin provides the 'docker compose' subcommand.
112+
.
113+
The binary can also be run standalone as a direct replacement for
114+
Docker Compose V1 ('docker-compose').
115+
Homepage: https://github.com/docker/compose
116+
105117
Package: docker-scan-plugin
106118
Priority: optional
107119
# TODO change once we support scan-plugin on other architectures (see dpkg-architecture -L)

deb/common/rules

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ 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 the compose plugin
20+
# FIXME: using GOPROXY, to work around:
21+
# 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
22+
cd /go/src/github.com/docker/compose \
23+
&& GOPROXY="https://proxy.golang.org" GO111MODULE=on go mod download \
24+
&& mkdir -p /usr/libexec/docker/cli-plugins/ \
25+
&& GOPROXY="https://proxy.golang.org" GO111MODULE=on GIT_TAG=$(COMPOSE_VERSION) \
26+
make COMPOSE_BINARY=/usr/libexec/docker/cli-plugins/docker-compose -f builder.Makefile compose-plugin
27+
1928
# Build the scan-plugin
2029
# TODO change once we support scan-plugin on other architectures
2130
if [ "$(TARGET_ARCH)" = "amd64" ]; then \
@@ -40,6 +49,9 @@ override_dh_auto_test:
4049
ver="$$(cli/build/docker --version)"; \
4150
test "$$ver" = "Docker version $(VERSION), build $(CLI_GITCOMMIT)" && echo "PASS: cli version OK" || (echo "FAIL: cli version ($$ver) did not match" && exit 1)
4251

52+
ver="$$(/usr/libexec/docker/cli-plugins/docker-compose docker-cli-plugin-metadata | awk '{ gsub(/[",:]/,"")}; $$1 == "Version" { print $$2 }')"; \
53+
test "$$ver" = "$(COMPOSE_VERSION)" && echo "PASS: docker-compose version OK" || (echo "FAIL: docker-compose version ($$ver) did not match" && exit 1)
54+
4355
# FIXME: --version currently doesn't work as it makes a connection to the daemon, so using the plugin metadata instead
4456
# TODO change once we support scan-plugin on other architectures
4557
if [ "$(TARGET_ARCH)" = "amd64" ]; then \
@@ -69,6 +81,9 @@ override_dh_auto_install:
6981
install -D -m 0755 $(shell readlink -e engine/bundles/dynbinary-daemon/docker-proxy) debian/docker-ce/usr/bin/docker-proxy
7082
install -D -m 0755 /usr/local/bin/docker-init debian/docker-ce/usr/bin/docker-init
7183

84+
# docker-compose-plugin install
85+
install -D -m 0755 /usr/libexec/docker/cli-plugins/docker-compose debian/docker-compose-plugin/usr/libexec/docker/cli-plugins/docker-compose
86+
7287
# docker-scan-plugin install
7388
# TODO change once we support scan-plugin on other architectures
7489
if [ "$(TARGET_ARCH)" = "amd64" ]; then \
@@ -95,6 +110,10 @@ override_dh_install:
95110
dh_apparmor --profile-name=docker-ce -pdocker-ce
96111

97112
override_dh_gencontrol:
113+
# Use separate version for the compose-plugin package, then generate the other control files as usual
114+
# TODO override "Source" field in control as well (to point to compose, as it doesn't match the package name)
115+
dh_gencontrol -pdocker-compose-plugin -- -v$${COMPOSE_VERSION#v}~$${DISTRO}-$${SUITE}
116+
98117
# Use separate version for the scan-plugin package, then generate the other control files as usual
99118
# TODO override "Source" field in control as well (to point to scan-cli-plugin, as it doesn't match the package name)
100119
# TODO change once we support scan-plugin on other architectures (see dpkg-architecture -L)

rpm/Makefile

Lines changed: 17 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_COMPOSE_RPM_VER=$(shell ./gen-rpm-ver $(realpath $(CURDIR)/../src/github.com/docker/compose) "$(DOCKER_COMPOSE_REF)")
78
GEN_SCAN_RPM_VER=$(shell ./gen-rpm-ver $(realpath $(CURDIR)/../src/github.com/docker/scan-cli-plugin) "$(DOCKER_SCAN_REF)")
89
CLI_GITCOMMIT?=$(shell cd $(realpath $(CURDIR)/../src/github.com/docker/cli) && git rev-parse --short HEAD)
910
ENGINE_GITCOMMIT?=$(shell cd $(realpath $(CURDIR)/../src/github.com/docker/docker) && git rev-parse --short HEAD)
@@ -22,9 +23,9 @@ BUILD?=DOCKER_BUILDKIT=1 \
2223

2324

2425
ifeq ($(ARCH),x86_64)
25-
SPEC_FILES?=docker-ce.spec docker-ce-cli.spec docker-ce-rootless-extras.spec docker-scan-plugin.spec
26+
SPEC_FILES?=docker-ce.spec docker-ce-cli.spec docker-ce-rootless-extras.spec docker-compose-plugin.spec docker-scan-plugin.spec
2627
else
27-
SPEC_FILES?=docker-ce.spec docker-ce-cli.spec docker-ce-rootless-extras.spec
28+
SPEC_FILES?=docker-ce.spec docker-ce-cli.spec docker-ce-rootless-extras.spec docker-compose-plugin.spec
2829
endif
2930

3031
SPECS?=$(addprefix SPECS/, $(SPEC_FILES))
@@ -34,6 +35,8 @@ RPMBUILD_FLAGS?=-ba\
3435
--define '_release $(word 2,$(GEN_RPM_VER))' \
3536
--define '_version $(word 1,$(GEN_RPM_VER))' \
3637
--define '_origversion $(word 4, $(GEN_RPM_VER))' \
38+
--define '_compose_rpm_version $(word 1,$(GEN_COMPOSE_RPM_VER))' \
39+
--define '_compose_version $(word 4,$(GEN_COMPOSE_RPM_VER))' \
3740
--define '_scan_rpm_version $(word 1,$(GEN_SCAN_RPM_VER))' \
3841
--define '_scan_version $(word 4,$(GEN_SCAN_RPM_VER))' \
3942
--define '_scan_gitcommit $(SCAN_GITCOMMIT)' \
@@ -87,13 +90,16 @@ centos: $(CENTOS_RELEASES) ## build all centos rpm packages
8790
rhel: $(RHEL_RELEASES) ## build all rhel rpm packages
8891

8992
.PHONY: $(DISTROS)
90-
$(DISTROS): rpmbuild/SOURCES/engine.tgz rpmbuild/SOURCES/cli.tgz rpmbuild/SOURCES/scan-cli-plugin.tgz rpmbuild/SOURCES/plugin-installers.tgz
93+
$(DISTROS): sources
9194
@echo "== Building packages for $@ =="
9295
mkdir -p "rpmbuild/$@"
9396
$(BUILD)
9497
$(RUN)
9598
$(CHOWN) -R $(shell id -u):$(shell id -g) "rpmbuild/$@"
9699

100+
.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
102+
97103
rpmbuild/SOURCES/engine.tgz:
98104
mkdir -p $(@D)
99105
docker run --rm -w /v \
@@ -110,6 +116,14 @@ rpmbuild/SOURCES/cli.tgz:
110116
alpine \
111117
tar -C / -c -z -f /v/cli.tgz --exclude .git cli
112118

119+
rpmbuild/SOURCES/compose.tgz:
120+
mkdir -p $(@D)
121+
docker run --rm -w /v \
122+
-v $(realpath $(CURDIR)/../src/github.com/docker/compose):/compose \
123+
-v $(CURDIR)/$(@D):/v \
124+
alpine \
125+
tar -C / -c -z -f /v/compose.tgz --exclude .git compose
126+
113127
rpmbuild/SOURCES/scan-cli-plugin.tgz:
114128
mkdir -p $(@D)
115129
docker run --rm -w /v \

rpm/SPECS/docker-compose-plugin.spec

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
%global debug_package %{nil}
2+
3+
Name: docker-compose-plugin
4+
Version: %{_compose_rpm_version}
5+
Release: %{_release}%{?dist}
6+
Epoch: 0
7+
Source0: compose.tgz
8+
Summary: Docker Compose (V2) plugin for the Docker CLI
9+
Group: Tools/Docker
10+
License: ASL 2.0
11+
URL: https://github.com/docker/compose/
12+
Vendor: Docker
13+
Packager: Docker <[email protected]>
14+
15+
BuildRequires: bash
16+
17+
%description
18+
Docker Compose (V2) plugin for the Docker CLI.
19+
20+
This plugin provides the 'docker compose' subcommand.
21+
22+
The binary can also be run standalone as a direct replacement for
23+
Docker Compose V1 ('docker-compose').
24+
25+
%prep
26+
%setup -q -c -n src -a 0
27+
28+
%build
29+
pushd ${RPM_BUILD_DIR}/src/compose
30+
# FIXME: using GOPROXY, to work around:
31+
# 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
32+
GOPROXY="https://proxy.golang.org" GO111MODULE=on go mod download
33+
GOPROXY="https://proxy.golang.org" GO111MODULE=on GIT_TAG="%{_compose_version}" \
34+
make COMPOSE_BINARY="bin/docker-compose" -f builder.Makefile compose-plugin
35+
popd
36+
37+
%check
38+
ver="$(${RPM_BUILD_ROOT}%{_libexecdir}/docker/cli-plugins/docker-compose docker-cli-plugin-metadata | awk '{ gsub(/[",:]/,"")}; $1 == "Version" { print $2 }')"; \
39+
test "$ver" = "%{_compose_version}" && echo "PASS: docker-compose version OK" || (echo "FAIL: docker-compose version ($ver) did not match" && exit 1)
40+
41+
%install
42+
pushd ${RPM_BUILD_DIR}/src/compose
43+
install -D -p -m 0755 bin/docker-compose ${RPM_BUILD_ROOT}%{_libexecdir}/docker/cli-plugins/docker-compose
44+
popd
45+
46+
for f in LICENSE MAINTAINERS NOTICE README.md; do
47+
install -D -p -m 0644 "${RPM_BUILD_DIR}/src/compose/$f" "docker-compose-plugin-docs/$f"
48+
done
49+
50+
%files
51+
%doc docker-compose-plugin-docs/*
52+
%license docker-compose-plugin-docs/LICENSE
53+
%license docker-compose-plugin-docs/NOTICE
54+
%{_libexecdir}/docker/cli-plugins/docker-compose
55+
56+
%post
57+
58+
%preun
59+
60+
%postun
61+
62+
%changelog

0 commit comments

Comments
 (0)