From e08abf851546dc60bb1b1619b6b7eb17290a67ad Mon Sep 17 00:00:00 2001 From: Eli Uriegas Date: Wed, 19 Sep 2018 14:26:03 -0700 Subject: [PATCH] Add metadata and alternate links Signed-off-by: Daniel Hiltgen --- deb/Makefile | 6 +++++- deb/common/docker-ce.postinst | 1 + deb/common/docker-ce.prerm | 5 +++++ deb/common/rules | 6 +++++- image/Dockerfile.engine | 16 ++++++++++++++++ image/Dockerfile.engine-dm | 16 ++++++++++++++++ rpm/Makefile | 6 +++++- rpm/SPECS/docker-ce.spec | 8 ++++++-- 8 files changed, 59 insertions(+), 5 deletions(-) create mode 100755 deb/common/docker-ce.prerm diff --git a/deb/Makefile b/deb/Makefile index f4c7691cb7..5c04779976 100644 --- a/deb/Makefile +++ b/deb/Makefile @@ -32,7 +32,7 @@ RUN=docker run --rm -i \ -v $(CURDIR)/debbuild/$@:/build \ debbuild-$@/$(ARCH) -SOURCE_FILES=engine-image cli.tgz docker.service +SOURCE_FILES=engine-image cli.tgz docker.service distribution_based_engine.json SOURCES=$(addprefix sources/, $(SOURCE_FILES)) .PHONY: help @@ -131,6 +131,10 @@ sources/docker.service: ../systemd/docker.service mkdir -p $(@D) cp $< $@ +sources/distribution_based_engine.json: sources/engine-image + mkdir -p $(@D) + docker inspect "$(shell cat sources/engine-image)" --format '{{ .Config.Labels.distribution_based_engine }}' > $@ + sources/engine-image: mkdir -p $(@D) $(MAKE) -C ../image image-linux diff --git a/deb/common/docker-ce.postinst b/deb/common/docker-ce.postinst index eeef6ca801..54c64bf4d1 100644 --- a/deb/common/docker-ce.postinst +++ b/deb/common/docker-ce.postinst @@ -7,6 +7,7 @@ case "$1" in if ! getent group docker > /dev/null; then groupadd --system docker fi + update-alternatives --install /usr/bin/dockerd dockerd /usr/bin/dockerd-ce 1 fi ;; abort-*) diff --git a/deb/common/docker-ce.prerm b/deb/common/docker-ce.prerm new file mode 100755 index 0000000000..02c320b549 --- /dev/null +++ b/deb/common/docker-ce.prerm @@ -0,0 +1,5 @@ +#!/bin/sh +set -e + +update-alternatives --remove dockerd /usr/bin/dockerd-ce + diff --git a/deb/common/rules b/deb/common/rules index 2e7acf4007..cc7e7a768a 100644 --- a/deb/common/rules +++ b/deb/common/rules @@ -21,9 +21,13 @@ override_dh_auto_install: install -D -m 0755 /go/src/github.com/docker/cli/build/docker debian/docker-ce-cli/usr/bin/docker # docker-ce install install -D -m 0644 /sources/docker.service debian/docker-ce/lib/systemd/system/docker.service - install -D -m 0755 /source/dockerd debian/docker-ce/usr/bin/dockerd + install -D -m 0755 /source/dockerd debian/docker-ce/usr/bin/dockerd-ce install -D -m 0755 /source/docker-proxy debian/docker-ce/usr/bin/docker-proxy install -D -m 0755 /source/docker-init debian/docker-ce/usr/bin/docker-init + install -D -m 0644 /sources/distribution_based_engine.json debian/docker-ce/var/lib/docker/distribution_based_engine.json + +override_dh_shlibdeps: + dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info override_dh_shlibdeps: dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info diff --git a/image/Dockerfile.engine b/image/Dockerfile.engine index 961e8b2dba..7c88aa7c4e 100644 --- a/image/Dockerfile.engine +++ b/image/Dockerfile.engine @@ -78,8 +78,24 @@ RUN . /binaries-commits && \ # Final docker image FROM scratch +ARG VERSION +ARG GITCOMMIT +ARG BUILDTIME +ARG PLATFORM COPY --from=dockerd-builder /sbin/dockerd /sbin/ COPY --from=proxy-builder /sbin/docker-proxy /sbin/ COPY --from=init-builder /sbin/docker-init /sbin/ COPY --from=runc-builder /usr/local/sbin/runc /sbin/ + +LABEL \ + org.opencontainers.image.authors="Docker Inc." \ + org.opencontainers.image.created="${BUILDTIME}" \ + org.opencontainers.image.documentation="https://docs.docker.com/" \ + org.opencontainers.image.licenses="Apache-2.0" \ + org.opencontainers.image.revision="${GITCOMMIT}" \ + org.opencontainers.image.url="https://www.docker.com/products/docker-engine" \ + org.opencontainers.image.vendor="Docker Inc." \ + org.opencontainers.image.version="${VERSION}" \ + distribution_based_engine="{\"platform\":\"${PLATFORM}\",\"containerd_min_version\":\"1.2.0-beta.1\",\"runtime\":\"host_install\"}" + ENTRYPOINT ["/sbin/dockerd"] diff --git a/image/Dockerfile.engine-dm b/image/Dockerfile.engine-dm index 2cf5521c4b..b587a5b4c7 100644 --- a/image/Dockerfile.engine-dm +++ b/image/Dockerfile.engine-dm @@ -74,7 +74,23 @@ RUN . /binaries-commits && \ # Final docker image FROM scratch +ARG VERSION +ARG GITCOMMIT +ARG BUILDTIME +ARG PLATFORM COPY --from=dockerd-builder /dockerd /sbin/ COPY --from=proxy-builder /docker-proxy /sbin/ COPY --from=init-builder /docker-init /sbin/ + +LABEL \ + org.opencontainers.image.authors="Docker Inc." \ + org.opencontainers.image.created="${BUILDTIME}" \ + org.opencontainers.image.documentation="https://docs.docker.com/" \ + org.opencontainers.image.licenses="Apache-2.0" \ + org.opencontainers.image.revision="${GITCOMMIT}" \ + org.opencontainers.image.url="https://www.docker.com/products/docker-engine" \ + org.opencontainers.image.vendor="Docker Inc." \ + org.opencontainers.image.version="${VERSION}" \ + distribution_based_engine="{\"platform\":\"${PLATFORM}\",\"containerd_min_version\":\"1.2.0-beta.1\",\"runtime\":\"host_install\"}" + ENTRYPOINT ["/sbin/dockerd"] diff --git a/rpm/Makefile b/rpm/Makefile index f35dca423e..2dad05a8ce 100644 --- a/rpm/Makefile +++ b/rpm/Makefile @@ -40,7 +40,7 @@ RPMBUILD_FLAGS?=-ba\ $(SPECS) RUN?=$(RPMBUILD) rpmbuild-$@/$(ARCH) $(RPMBUILD_FLAGS) -SOURCE_FILES=engine-image cli.tgz docker.service +SOURCE_FILES=engine-image cli.tgz docker.service distribution_based_engine.json SOURCES=$(addprefix rpmbuild/SOURCES/, $(SOURCE_FILES)) @@ -102,3 +102,7 @@ rpmbuild/SOURCES/engine-image: $(MAKE) -C ../image image-linux-dm mkdir -p $(@D) cp ../image/image-linux-dm $@ + +rpmbuild/SOURCES/distribution_based_engine.json: + mkdir -p $(@D) + docker inspect "$(shell cat rpmbuild/SOURCES/engine-image)" --format '{{ .Config.Labels.distribution_based_engine }}' > $@ diff --git a/rpm/SPECS/docker-ce.spec b/rpm/SPECS/docker-ce.spec index f568e0fdeb..014774d4d6 100644 --- a/rpm/SPECS/docker-ce.spec +++ b/rpm/SPECS/docker-ce.spec @@ -52,16 +52,18 @@ depending on a particular stack or provider. %install # Install containerd-proxy as dockerd -install -D -m 0755 /sources/dockerd $RPM_BUILD_ROOT/%{_bindir}/dockerd +install -D -m 0755 /sources/dockerd $RPM_BUILD_ROOT/%{_bindir}/dockerd-ce install -D -m 0755 /sources/docker-proxy $RPM_BUILD_ROOT/%{_bindir}/docker-proxy install -D -m 0755 /sources/docker-init $RPM_BUILD_ROOT/%{_bindir}/docker-init install -D -m 0644 %{_topdir}/SOURCES/docker.service $RPM_BUILD_ROOT/%{_unitdir}/docker.service +install -D -m 0644 %{_topdir}/SOURCES/distribution_based_engine.json $RPM_BUILD_ROOT/var/lib/docker/distribution_based_engine.json %files -/%{_bindir}/dockerd +/%{_bindir}/dockerd-ce /%{_bindir}/docker-proxy /%{_bindir}/docker-init /%{_unitdir}/docker.service +/var/lib/docker/distribution_based_engine.json %pre if [ $1 -gt 0 ] ; then @@ -82,9 +84,11 @@ fi if ! getent group docker > /dev/null; then groupadd --system docker fi +update-alternatives --install /usr/bin/dockerd dockerd /usr/bin/dockerd-ce 1 %preun %systemd_preun docker +update-alternatives --remove dockerd /usr/bin/dockerd-ce %postun %systemd_postun_with_restart docker