Skip to content

Commit 8840a50

Browse files
authored
Merge pull request #1190 from xenoscopic/docker-model-packaging
all: add rules for docker-model-plugin packages
2 parents da7a66a + cefea11 commit 8840a50

File tree

10 files changed

+121
-5
lines changed

10 files changed

+121
-5
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/buildx src/github.com/docker/compose ## 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/model-cli ## clone source
1919

2020
ifdef CLI_DIR
2121
src/github.com/docker/cli:
@@ -45,6 +45,10 @@ src/github.com/docker/compose:
4545
git init $@
4646
git -C $@ remote add origin "$(DOCKER_COMPOSE_REPO)"
4747

48+
src/github.com/docker/model-cli:
49+
git init $@
50+
git -C $@ remote add origin "$(DOCKER_MODEL_REPO)"
51+
4852
.PHONY: checkout-cli
4953
checkout-cli: src/github.com/docker/cli
5054
./scripts/checkout.sh src/github.com/docker/cli "$(DOCKER_CLI_REF)"
@@ -61,8 +65,12 @@ checkout-buildx: src/github.com/docker/buildx
6165
checkout-compose: src/github.com/docker/compose
6266
./scripts/checkout.sh src/github.com/docker/compose "$(DOCKER_COMPOSE_REF)"
6367

68+
.PHONY: checkout-model
69+
checkout-model: src/github.com/docker/model-cli
70+
./scripts/checkout.sh src/github.com/docker/model-cli "$(DOCKER_MODEL_REF)"
71+
6472
.PHONY: checkout
65-
checkout: checkout-cli checkout-docker checkout-buildx checkout-compose ## checkout source at the given reference(s)
73+
checkout: checkout-cli checkout-docker checkout-buildx checkout-compose checkout-model ## checkout source at the given reference(s)
6674

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

common.mk

Lines changed: 4 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_COMPOSE_REPO ?= https://github.com/docker/compose.git
3030
DOCKER_BUILDX_REPO ?= https://github.com/docker/buildx.git
31+
DOCKER_MODEL_REPO ?= https://github.com/docker/model-cli.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
@@ -44,6 +45,9 @@ DOCKER_COMPOSE_REF ?= v2.36.0
4445
# DOCKER_BUILDX_REF is the version of compose to package. It usually is a tag,
4546
# but can be a valid git reference in DOCKER_BUILDX_REPO.
4647
DOCKER_BUILDX_REF ?= v0.23.0
48+
# DOCKER_MODEL_REF is the version of model to package. It is usually a tag,
49+
# but can be a valid git reference in DOCKER_MODEL_REPO.
50+
DOCKER_MODEL_REF ?= v0.1.23
4751

4852
# Use "stage" to install dependencies from download-stage.docker.com during the
4953
# verify step. Leave empty or use any other value to install from download.docker.com

deb/Makefile

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ EPOCH?=5
77
GEN_DEB_VER=$(shell ./gen-deb-ver $(realpath $(CURDIR)/../src/github.com/docker/cli) "$(VERSION)")
88
GEN_BUILDX_DEB_VER=$(shell ./gen-deb-ver $(realpath $(CURDIR)/../src/github.com/docker/buildx) "$(DOCKER_BUILDX_REF)")
99
GEN_COMPOSE_DEB_VER=$(shell ./gen-deb-ver $(realpath $(CURDIR)/../src/github.com/docker/compose) "$(DOCKER_COMPOSE_REF)")
10+
GEN_MODEL_DEB_VER=$(shell ./gen-deb-ver $(realpath $(CURDIR)/../src/github.com/docker/model-cli) "$(DOCKER_MODEL_REF)")
1011
CLI_GITCOMMIT?=$(shell cd $(realpath $(CURDIR)/../src/github.com/docker/cli) && git rev-parse --short HEAD)
1112
ENGINE_GITCOMMIT?=$(shell cd $(realpath $(CURDIR)/../src/github.com/docker/docker) && git rev-parse --short HEAD)
1213
BUILDX_GITCOMMIT?=$(shell cd $(realpath $(CURDIR)/../src/github.com/docker/buildx) && git rev-parse --short HEAD)
@@ -46,6 +47,8 @@ RUN?=docker run --rm \
4647
-e BUILDX_GITCOMMIT=$(BUILDX_GITCOMMIT) \
4748
-e COMPOSE_VERSION=$(DOCKER_COMPOSE_REF) \
4849
-e COMPOSE_DEB_VERSION=$(word 1, $(GEN_COMPOSE_DEB_VER)) \
50+
-e MODEL_VERSION=$(DOCKER_MODEL_REF) \
51+
-e MODEL_DEB_VERSION=$(word 1, $(GEN_MODEL_DEB_VER)) \
4952
-v $(CURDIR)/debbuild/$@:/build \
5053
$(RUN_FLAGS) \
5154
debbuild-$@/$(ARCH)
@@ -88,7 +91,7 @@ $(DISTROS): sources
8891
$(CHOWN) -R $(shell id -u):$(shell id -g) "debbuild/$@"
8992

9093
.PHONY: sources
91-
sources: sources/cli.tgz sources/engine.tgz sources/buildx.tgz sources/compose.tgz
94+
sources: sources/cli.tgz sources/engine.tgz sources/buildx.tgz sources/compose.tgz sources/model.tgz
9295

9396
sources/engine.tgz:
9497
mkdir -p $(@D)
@@ -122,6 +125,14 @@ sources/compose.tgz:
122125
alpine \
123126
tar -C / -c -z -f /v/compose.tgz --exclude .git compose
124127

128+
sources/model.tgz:
129+
mkdir -p $(@D)
130+
docker run --rm -w /v \
131+
-v $(realpath $(CURDIR)/../src/github.com/docker/model-cli):/model \
132+
-v $(CURDIR)/$(@D):/v \
133+
alpine \
134+
tar -C / -c -z -f /v/model.tgz --exclude .git model
135+
125136
# See ARCHES in common.mk. Could not figure out how to match both distro and arch.
126137
BUNDLES:=$(addsuffix .tar.gz,$(addprefix debbuild/bundles-ce-%-,$(ARCHES)))
127138

deb/build-deb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,16 @@ mkdir -p /root/build-deb/buildx
1111
tar -C /root/build-deb -xzf /sources/buildx.tgz
1212
mkdir -p /root/build-deb/compose
1313
tar -C /root/build-deb -xzf /sources/compose.tgz
14+
mkdir -p /root/build-deb/model
15+
tar -C /root/build-deb -xzf /sources/model.tgz
1416

1517
# link them to their canonical path
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
1921
ln -snf /root/build-deb/buildx /go/src/github.com/docker/buildx
2022
ln -snf /root/build-deb/compose /go/src/github.com/docker/compose
23+
ln -snf /root/build-deb/model /go/src/github.com/docker/model-cli
2124

2225
EPOCH="${EPOCH:-}"
2326
EPOCH_SEP=""

deb/common/control

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ Architecture: linux-any
5858
Depends: ${shlibs:Depends}
5959
Recommends: docker-buildx-plugin,
6060
docker-compose-plugin
61+
Suggests: docker-model-plugin
6162
Conflicts: docker (<< 1.5~),
6263
docker-engine,
6364
docker.io
@@ -113,3 +114,12 @@ Description: Docker Compose (V2) plugin for the Docker CLI.
113114
The binary can also be run standalone as a direct replacement for
114115
Docker Compose V1 ('docker-compose').
115116
Homepage: https://github.com/docker/compose
117+
118+
Package: docker-model-plugin
119+
Priority: optional
120+
Architecture: linux-any
121+
Enhances: docker-ce-cli
122+
Description: Docker Model Runner plugin for the Docker CLI.
123+
.
124+
This plugin provides the 'docker model' subcommand.
125+
Homepage: https://docs.docker.com/model-runner/

deb/common/rules

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ override_dh_auto_build:
4747
# Build the compose plugin
4848
make -C /go/src/github.com/docker/compose VERSION=$(COMPOSE_VERSION) DESTDIR=/usr/libexec/docker/cli-plugins build
4949

50+
# Build the model plugin
51+
GO111MODULE=on make -C /go/src/github.com/docker/model-cli VERSION=$(MODEL_VERSION) ce-release \
52+
&& mv /go/src/github.com/docker/model-cli/dist/docker-model /usr/libexec/docker/cli-plugins/docker-model
53+
5054
override_dh_auto_test:
5155
ver="$$(engine/bundles/dynbinary-daemon/dockerd --version)"; \
5256
test "$$ver" = "Docker version $(VERSION), build $(ENGINE_GITCOMMIT)" && echo "PASS: daemon version OK" || (echo "FAIL: daemon version ($$ver) did not match" && exit 1)
@@ -60,6 +64,9 @@ override_dh_auto_test:
6064
ver="$$(/usr/libexec/docker/cli-plugins/docker-compose docker-cli-plugin-metadata | awk '{ gsub(/[",:]/,"")}; $$1 == "Version" { print $$2 }')"; \
6165
test "$$ver" = "$(COMPOSE_VERSION)" && echo "PASS: docker-compose version OK" || (echo "FAIL: docker-compose version ($$ver) did not match" && exit 1)
6266

67+
ver="$$(/usr/libexec/docker/cli-plugins/docker-model docker-cli-plugin-metadata | awk '{ gsub(/[",:]/,"")}; $$1 == "Version" { print $$2 }')"; \
68+
test "$$ver" = "$(MODEL_VERSION)" && echo "PASS: docker-model version OK" || (echo "FAIL: docker-model version ($$ver) did not match" && exit 1)
69+
6370
override_dh_strip:
6471
# Go has lots of problems with stripping, so just don't
6572

@@ -117,6 +124,9 @@ override_dh_auto_install:
117124
# docker-compose-plugin install
118125
install -D -p -m 0755 /usr/libexec/docker/cli-plugins/docker-compose debian/docker-compose-plugin/usr/libexec/docker/cli-plugins/docker-compose
119126

127+
# docker-model-plugin install
128+
install -D -p -m 0755 /usr/libexec/docker/cli-plugins/docker-model debian/docker-model-plugin/usr/libexec/docker/cli-plugins/docker-model
129+
120130
# docker-ce-rootless-extras install
121131
install -D -p -m 0755 /usr/local/bin/rootlesskit debian/docker-ce-rootless-extras/usr/bin/rootlesskit
122132
install -D -p -m 0755 engine/contrib/dockerd-rootless.sh debian/docker-ce-rootless-extras/usr/bin/dockerd-rootless.sh
@@ -148,6 +158,10 @@ override_dh_gencontrol:
148158
# TODO override "Source" field in control as well (to point to compose, as it doesn't match the package name)
149159
dh_gencontrol -pdocker-compose-plugin -- -v$${COMPOSE_DEB_VERSION#v}-$${PKG_REVISION}~$${DISTRO}.$${VERSION_ID}~$${SUITE}
150160

161+
# Use separate version for the model-plugin package, then generate the other control files as usual
162+
# TODO override "Source" field in control as well (to point to model, as it doesn't match the package name)
163+
dh_gencontrol -pdocker-model-plugin -- -v$${MODEL_DEB_VERSION#v}-$${PKG_REVISION}~$${DISTRO}.$${VERSION_ID}~$${SUITE}
164+
151165
dh_gencontrol --remaining-packages
152166

153167
%:

rpm/Makefile

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ GO_IMAGE?=$(GO_BASE_IMAGE):$(GO_VERSION)-bookworm
66
GEN_RPM_VER=$(shell ./gen-rpm-ver $(realpath $(CURDIR)/../src/github.com/docker/cli) "$(VERSION)")
77
GEN_BUILDX_RPM_VER=$(shell ./gen-rpm-ver $(realpath $(CURDIR)/../src/github.com/docker/buildx) "$(DOCKER_BUILDX_REF)")
88
GEN_COMPOSE_RPM_VER=$(shell ./gen-rpm-ver $(realpath $(CURDIR)/../src/github.com/docker/compose) "$(DOCKER_COMPOSE_REF)")
9+
GEN_MODEL_RPM_VER=$(shell ./gen-rpm-ver $(realpath $(CURDIR)/../src/github.com/docker/model-cli) "$(DOCKER_MODEL_REF)")
910
CLI_GITCOMMIT?=$(shell cd $(realpath $(CURDIR)/../src/github.com/docker/cli) && git rev-parse --short HEAD)
1011
ENGINE_GITCOMMIT?=$(shell cd $(realpath $(CURDIR)/../src/github.com/docker/docker) && git rev-parse --short HEAD)
1112
BUILDX_GITCOMMIT?=$(shell cd $(realpath $(CURDIR)/../src/github.com/docker/buildx) && git rev-parse --short HEAD)
@@ -27,7 +28,7 @@ BUILD?=DOCKER_BUILDKIT=1 \
2728
.
2829

2930

30-
SPEC_FILES?=docker-ce.spec docker-ce-cli.spec docker-ce-rootless-extras.spec docker-buildx-plugin.spec docker-compose-plugin.spec
31+
SPEC_FILES?=docker-ce.spec docker-ce-cli.spec docker-ce-rootless-extras.spec docker-buildx-plugin.spec docker-compose-plugin.spec docker-model-plugin.spec
3132

3233
SPECS?=$(addprefix SPECS/, $(SPEC_FILES))
3334
RPMBUILD_FLAGS?=-ba\
@@ -41,6 +42,8 @@ RPMBUILD_FLAGS?=-ba\
4142
--define '_buildx_gitcommit $(BUILDX_GITCOMMIT)' \
4243
--define '_compose_rpm_version $(word 1,$(GEN_COMPOSE_RPM_VER))' \
4344
--define '_compose_version $(word 4,$(GEN_COMPOSE_RPM_VER))' \
45+
--define '_model_rpm_version $(word 1,$(GEN_MODEL_RPM_VER))' \
46+
--define '_model_version $(word 4,$(GEN_MODEL_RPM_VER))' \
4447
$(RPMBUILD_EXTRA_FLAGS) \
4548
$(SPECS)
4649

@@ -99,7 +102,7 @@ $(DISTROS): sources
99102
$(CHOWN) -R $(shell id -u):$(shell id -g) "rpmbuild/$@"
100103

101104
.PHONY: sources
102-
sources: rpmbuild/SOURCES/engine.tgz rpmbuild/SOURCES/cli.tgz rpmbuild/SOURCES/buildx.tgz rpmbuild/SOURCES/compose.tgz
105+
sources: rpmbuild/SOURCES/engine.tgz rpmbuild/SOURCES/cli.tgz rpmbuild/SOURCES/buildx.tgz rpmbuild/SOURCES/compose.tgz rpmbuild/SOURCES/model.tgz
103106

104107
rpmbuild/SOURCES/engine.tgz:
105108
mkdir -p $(@D)
@@ -133,6 +136,14 @@ rpmbuild/SOURCES/compose.tgz:
133136
alpine \
134137
tar -C / -c -z -f /v/compose.tgz --exclude .git compose
135138

139+
rpmbuild/SOURCES/model.tgz:
140+
mkdir -p $(@D)
141+
docker run --rm -w /v \
142+
-v $(realpath $(CURDIR)/../src/github.com/docker/model-cli):/model \
143+
-v $(CURDIR)/$(@D):/v \
144+
alpine \
145+
tar -C / -c -z -f /v/model.tgz --exclude .git model
146+
136147
# See ARCHES in common.mk. Could not figure out how to match both distro and arch.
137148
BUNDLES:=$(addsuffix .tar.gz,$(addprefix rpmbuild/bundles-ce-%-,$(ARCHES)))
138149

rpm/SPECS/docker-ce-cli.spec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ Requires: /usr/sbin/groupadd
1919
Recommends: docker-buildx-plugin
2020
Recommends: docker-compose-plugin
2121

22+
Suggests: docker-model-plugin
23+
2224
BuildRequires: make
2325
BuildRequires: libtool-ltdl-devel
2426
BuildRequires: git

rpm/SPECS/docker-model-plugin.spec

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
%global debug_package %{nil}
2+
3+
Name: docker-model-plugin
4+
Version: %{_model_rpm_version}
5+
Release: %{_release}%{?dist}
6+
Epoch: 0
7+
Source0: model.tgz
8+
Summary: Docker Model Runner plugin for the Docker CLI
9+
Group: Tools/Docker
10+
License: Apache-2.0
11+
URL: https://docs.docker.com/model-runner/
12+
Vendor: Docker
13+
Packager: Docker <[email protected]>
14+
15+
Enhances: docker-ce-cli
16+
17+
BuildRequires: bash
18+
19+
%description
20+
Docker Model Runner plugin for the Docker CLI.
21+
22+
This plugin provides the 'docker model' subcommand.
23+
24+
%prep
25+
%setup -q -c -n src -a 0
26+
27+
%build
28+
GO111MODULE=on make -C ${RPM_BUILD_DIR}/src/model VERSION=%{_model_version} ce-release
29+
30+
%check
31+
ver="$(${RPM_BUILD_ROOT}%{_libexecdir}/docker/cli-plugins/docker-model docker-cli-plugin-metadata | awk '{ gsub(/[",:]/,"")}; $1 == "Version" { print $2 }')"; \
32+
test "$ver" = "%{_model_version}" && echo "PASS: docker-model version OK" || (echo "FAIL: docker-model version ($ver) did not match" && exit 1)
33+
34+
%install
35+
install -D -p -m 0755 ${RPM_BUILD_DIR}/src/model/dist/docker-model ${RPM_BUILD_ROOT}%{_libexecdir}/docker/cli-plugins/docker-model
36+
37+
for f in LICENSE; do
38+
install -D -p -m 0644 "${RPM_BUILD_DIR}/src/model/$f" "docker-model-plugin-docs/$f"
39+
done
40+
41+
%files
42+
%doc docker-model-plugin-docs/*
43+
%license docker-model-plugin-docs/LICENSE
44+
%{_libexecdir}/docker/cli-plugins/docker-model
45+
46+
%post
47+
48+
%preun
49+
50+
%postun
51+
52+
%changelog

verify

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ function verify_binaries() {
2929
docker --version
3030
docker buildx version
3131
docker compose version
32+
docker model version
3233
dockerd --version
3334
docker-proxy --version
3435
containerd --version

0 commit comments

Comments
 (0)