Skip to content

Commit

Permalink
deb: add docker-compose-plugin package
Browse files Browse the repository at this point in the history
Adds a deb package for the docker-compose cli plugin

with this:

    dpkg -i ./docker-ce-cli_0.0.0-20210629140245-4a6fe51-0~ubuntu-focal_amd64.deb
    dpkg -i ./docker-compose-plugin_2.0.0-beta.4~ubuntu-focal_amd64.deb

    docker info --format '{{json .ClientInfo.Plugins}}' | jq .
    [
      {
        "SchemaVersion": "0.1.0",
        "Vendor": "Docker Inc.",
        "Version": "v0.5.1-docker",
        "ShortDescription": "Build with BuildKit",
        "Name": "buildx",
        "Path": "/usr/libexec/docker/cli-plugins/docker-buildx"
      },
      {
        "SchemaVersion": "0.1.0",
        "Vendor": "Docker Inc.",
        "Version": "2.0.0-beta.4",
        "ShortDescription": "Docker Compose",
        "Name": "compose",
        "Path": "/usr/libexec/docker/cli-plugins/docker-compose"
      }
    ]

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
  • Loading branch information
thaJeztah committed Jul 3, 2021
1 parent 4cd3a7e commit 536092f
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 6 deletions.
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ clean-src:
$(RM) -r src

.PHONY: src
src: src/github.com/docker/cli src/github.com/docker/docker src/github.com/docker/scan-cli-plugin ## clone source
src: src/github.com/docker/cli src/github.com/docker/docker src/github.com/docker/compose-cli src/github.com/docker/scan-cli-plugin ## clone source

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

src/github.com/docker/compose-cli:
git init $@
git -C $@ remote add origin "$(DOCKER_COMPOSE_REPO)"

src/github.com/docker/scan-cli-plugin:
git init $@
git -C $@ remote add origin "$(DOCKER_SCAN_REPO)"
Expand All @@ -50,12 +54,16 @@ checkout-cli: src/github.com/docker/cli
checkout-docker: src/github.com/docker/docker
./scripts/checkout.sh src/github.com/docker/docker "$(DOCKER_ENGINE_REF)"

.PHONY: checkout-compose-cli
checkout-compose-cli: src/github.com/docker/compose-cli
./scripts/checkout.sh src/github.com/docker/compose-cli "$(DOCKER_COMPOSE_REF)"

.PHONY: checkout-scan-cli-plugin
checkout-scan-cli-plugin: src/github.com/docker/scan-cli-plugin
./scripts/checkout.sh src/github.com/docker/scan-cli-plugin "$(DOCKER_SCAN_REF)"

.PHONY: checkout
checkout: checkout-cli checkout-docker checkout-scan-cli-plugin ## checkout source at the given reference(s)
checkout: checkout-cli checkout-docker checkout-compose-cli checkout-scan-cli-plugin ## checkout source at the given reference(s)

.PHONY: clean
clean: clean-src ## remove build artifacts
Expand Down
8 changes: 5 additions & 3 deletions common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ VERSION?=0.0.1-dev

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

# REF can be used to specify the same branch or tag to use for *both* the CLI
# and Engine source code. This can be useful if both the CLI and Engine have a
Expand All @@ -37,6 +38,7 @@ REF ?= HEAD
DOCKER_CLI_REF ?= $(REF)
DOCKER_ENGINE_REF ?= $(REF)
DOCKER_SCAN_REF ?= v0.8.0
DOCKER_COMPOSE_REF ?= v2.0.0-beta.4

export BUILDTIME
export DEFAULT_PRODUCT_LICENSE
Expand Down
11 changes: 10 additions & 1 deletion deb/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ RUN?=docker run --rm \
-e VERSION=$(word 2, $(GEN_DEB_VER)) \
-e CLI_GITCOMMIT=$(CLI_GITCOMMIT) \
-e ENGINE_GITCOMMIT=$(ENGINE_GITCOMMIT) \
-e COMPOSE_VERSION=$(DOCKER_COMPOSE_REF) \
-e SCAN_VERSION=$(DOCKER_SCAN_REF) \
-e SCAN_GITCOMMIT=$(SCAN_GITCOMMIT) \
-v $(CURDIR)/debbuild/$@:/build \
Expand Down Expand Up @@ -77,7 +78,7 @@ $(DISTROS): sources
$(CHOWN) -R $(shell id -u):$(shell id -g) "debbuild/$@"

.PHONY: sources
sources: sources/cli.tgz sources/engine.tgz sources/scan-cli-plugin.tgz sources/plugin-installers.tgz
sources: sources/cli.tgz sources/engine.tgz sources/compose-cli.tgz sources/scan-cli-plugin.tgz sources/plugin-installers.tgz

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

sources/compose-cli.tgz:
mkdir -p $(@D)
docker run --rm -w /v \
-v $(realpath $(CURDIR)/../src/github.com/docker/compose-cli):/compose-cli \
-v $(CURDIR)/$(@D):/v \
alpine \
tar -C / -c -z -f /v/compose-cli.tgz --exclude .git compose-cli

sources/scan-cli-plugin.tgz:
mkdir -p $(@D)
docker run --rm -w /v \
Expand Down
3 changes: 3 additions & 0 deletions deb/build-deb
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ mkdir -p /root/build-deb/engine
tar -C /root/build-deb -xzf /sources/engine.tgz
mkdir -p /root/build-deb/cli
tar -C /root/build-deb -xzf /sources/cli.tgz
mkdir -p /root/build-deb/compose-cli
tar -C /root/build-deb -xzf /sources/compose-cli.tgz
mkdir -p /root/build-deb/scan-cli-plugin
tar -C /root/build-deb -xzf /sources/scan-cli-plugin.tgz

# link them to their canonical path
mkdir -p /go/src/github.com/docker
ln -snf /root/build-deb/engine /go/src/github.com/docker/docker
ln -snf /root/build-deb/cli /go/src/github.com/docker/cli
ln -snf /root/build-deb/compose-cli /go/src/github.com/docker/compose-cli
ln -snf /root/build-deb/scan-cli-plugin /go/src/github.com/docker/scan-cli-plugin

EPOCH="${EPOCH:-}"
Expand Down
7 changes: 7 additions & 0 deletions deb/common/control
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ Description: Rootless support for Docker.
Either VPNKit or slirp4netns (>= 0.4.0) needs to be installed separately.
Homepage: https://docs.docker.com/engine/security/rootless/

Package: docker-compose-plugin
Priority: optional
Architecture: linux-any
Enhances: docker-ce-cli
Description: Docker compose cli plugin.
Homepage: https://github.com/docker/compose-cli

Package: docker-scan-plugin
Priority: optional
# TODO change once we support scan-plugin on other architectures (see dpkg-architecture -L)
Expand Down
19 changes: 19 additions & 0 deletions deb/common/rules
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ override_dh_auto_build:
# Build the CLI
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

# Build the compose-cli plugin
# FIXME: using GOPROXY, to work around:
# go: github.com/Azure/azure-sdk-for-go@v48.2.0+incompatible: reading github.com/Azure/azure-sdk-for-go/go.mod at revision v48.2.0: unknown revision v48.2.0
cd /go/src/github.com/docker/compose-cli \
&& GOPROXY="https://proxy.golang.org" GO111MODULE=on go mod download \
&& mkdir -p /usr/libexec/docker/cli-plugins/ \
&& GOPROXY="https://proxy.golang.org" GO111MODULE=on GIT_TAG=$(COMPOSE_VERSION) \
make COMPOSE_BINARY=/usr/libexec/docker/cli-plugins/docker-compose -f builder.Makefile compose-plugin

# Build the scan-plugin
# TODO change once we support scan-plugin on other architectures
if [ "$(TARGET_ARCH)" = "amd64" ]; then \
Expand All @@ -35,6 +44,9 @@ override_dh_auto_test:
ver="$$(cli/build/docker --version)"; \
test "$$ver" = "Docker version $(VERSION), build $(CLI_GITCOMMIT)" && echo "PASS: cli version OK" || echo "FAIL: cli version ($$ver) did not match"

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

# FIXME: --version currently doesn't work as it makes a connection to the daemon, so using the plugin metadata instead
ver="$$(/usr/libexec/docker/cli-plugins/docker-scan docker-cli-plugin-metadata | awk '{ gsub(/[",:]/,"")}; $$1 == "Version" { print $$2 }')"; \
test "$$ver" = "$(SCAN_VERSION)" && echo "PASS: docker-scan version OK" || echo "FAIL: docker-scan version ($$ver) did not match"
Expand All @@ -61,6 +73,9 @@ override_dh_auto_install:
install -D -m 0755 $(shell readlink -e engine/bundles/dynbinary-daemon/docker-proxy) debian/docker-ce/usr/bin/docker-proxy
install -D -m 0755 /usr/local/bin/docker-init debian/docker-ce/usr/bin/docker-init

# docker-compose-plugin install
install -D -m 0755 /usr/libexec/docker/cli-plugins/docker-compose debian/docker-compose-plugin/usr/libexec/docker/cli-plugins/docker-compose

# docker-scan-plugin install
# TODO change once we support scan-plugin on other architectures
if [ "$(TARGET_ARCH)" = "amd64" ]; then \
Expand All @@ -87,6 +102,10 @@ override_dh_install:
dh_apparmor --profile-name=docker-ce -pdocker-ce

override_dh_gencontrol:
# Use separate version for the compose-plugin package, then generate the other control files as usual
# TODO override "Source" field in control as well (to point to compose-cli, as it doesn't match the package name)
dh_gencontrol -pdocker-compose-plugin -- -v$${COMPOSE_VERSION#v}~$${DISTRO}-$${SUITE}; \

# Use separate version for the scan-plugin package, then generate the other control files as usual
# TODO override "Source" field in control as well (to point to scan-cli-plugin, as it doesn't match the package name)
# TODO change once we support scan-plugin on other architectures (see dpkg-architecture -L)
Expand Down

0 comments on commit 536092f

Please sign in to comment.