From 360ecbe77755b77a6eeda149816659440e557f89 Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Mon, 8 Nov 2021 15:19:23 +0100 Subject: [PATCH 1/4] Bump version post 2.7.0-rc.2 release Signed-off-by: Evan Lezar --- Makefile | 2 +- debian/changelog | 4 ++++ rpm/SPECS/nvidia-docker2.spec | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a8f8a7bf..e574ed4b 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ LIB_NAME := nvidia-docker2 LIB_VERSION := 2.7.0 -LIB_TAG := rc.2 +LIB_TAG ?= rc.3 TOOLKIT_VERSION ?= 1.6.0 TOOLKIT_TAG ?= rc.2 diff --git a/debian/changelog b/debian/changelog index 0d542520..ab53cb1d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,7 @@ +nvidia-docker2 (2.7.0~rc.3-1) UNRELEASED; urgency=medium + + -- NVIDIA CORPORATION Mon, 08 Nov 2021 14:54:46 +0100 + nvidia-docker2 (2.7.0~rc.2-1) UNRELEASED; urgency=medium * Allow the toolkit version to be specified as a variable diff --git a/rpm/SPECS/nvidia-docker2.spec b/rpm/SPECS/nvidia-docker2.spec index 78f3f174..2552dfec 100644 --- a/rpm/SPECS/nvidia-docker2.spec +++ b/rpm/SPECS/nvidia-docker2.spec @@ -37,6 +37,8 @@ install -m 644 -t %{buildroot}/etc/docker daemon.json %config /etc/docker/daemon.json %changelog +* Mon Nov 08 2021 NVIDIA CORPORATION 2.7.0-0.1.rc.3 + * Thu Nov 04 2021 NVIDIA CORPORATION 2.7.0-0.1.rc.2 - Bump nvidia-container-toolkit dependency to %{toolkit_version} - Allow the toolkit version to be specified as a variable From 4be436901e68dce7e1a6043bc673b38c35b4e382 Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Mon, 8 Nov 2021 15:24:22 +0100 Subject: [PATCH 2/4] Create empty changelog with single entry for release for deb packages In order to be able to specify the package version explicitly when builing a package, we create an empty changelog with a single entry on release. This invalidates the changelog which is moved to changelog.old Signed-off-by: Evan Lezar --- debian/{changelog => changelog.old} | 0 docker/Dockerfile.debian | 9 ++++++--- docker/Dockerfile.ubuntu | 11 +++++++---- 3 files changed, 13 insertions(+), 7 deletions(-) rename debian/{changelog => changelog.old} (100%) diff --git a/debian/changelog b/debian/changelog.old similarity index 100% rename from debian/changelog rename to debian/changelog.old diff --git a/docker/Dockerfile.debian b/docker/Dockerfile.debian index 1e013012..b5677afc 100644 --- a/docker/Dockerfile.debian +++ b/docker/Dockerfile.debian @@ -18,13 +18,14 @@ ARG DOCKER_VERSION ENV DEBFULLNAME "NVIDIA CORPORATION" ENV DEBEMAIL "cudatools@nvidia.com" +ENV PKG_NAME "nvidia-docker2" ENV REVISION "$PKG_VERS-$PKG_REV" ENV DOCKER_VERSION $DOCKER_VERSION ENV TOOLKIT_VERSION $TOOLKIT_VERSION ENV SECTION "" # output directory -ENV DIST_DIR=/tmp/nvidia-docker2-$PKG_VERS +ENV DIST_DIR=/tmp/${PKG_NAME}-$PKG_VERS RUN mkdir -p $DIST_DIR /dist # nvidia-docker 2.0 @@ -36,8 +37,10 @@ COPY debian ./debian RUN sed -i "s;@VERSION@;${PKG_VERS};" $DIST_DIR/nvidia-docker RUN sed -i "s;@TOOLKIT_VERSION@;${TOOLKIT_VERSION};" debian/control && \ - dch --changelog debian/changelog --append "Bump nvidia-container-toolkit dependency to ${TOOLKIT_VERSION}" && \ - dch --changelog debian/changelog -r "" && \ + dch --create --package="${PKG_NAME}" \ + --newversion "${REVISION}" \ + "Bump nvidia-container-toolkit dependency to ${TOOLKIT_VERSION}" && \ + dch -r "" && \ if [ "$REVISION" != "$(dpkg-parsechangelog --show-field=Version)" ]; then exit 1; fi CMD export DISTRIB="unstable" && \ diff --git a/docker/Dockerfile.ubuntu b/docker/Dockerfile.ubuntu index afd6fe04..bd48fbb3 100644 --- a/docker/Dockerfile.ubuntu +++ b/docker/Dockerfile.ubuntu @@ -19,13 +19,14 @@ ARG DOCKER_VERSION ENV DEBFULLNAME "NVIDIA CORPORATION" ENV DEBEMAIL "cudatools@nvidia.com" +ENV PKG_NAME "nvidia-docker2" ENV REVISION "$PKG_VERS-$PKG_REV" ENV DOCKER_VERSION $DOCKER_VERSION ENV TOOLKIT_VERSION $TOOLKIT_VERSION ENV SECTION "" # output directory -ENV DIST_DIR=/tmp/nvidia-docker2-$PKG_VERS +ENV DIST_DIR=/tmp/${PKG_NAME}-$PKG_VERS RUN mkdir -p $DIST_DIR /dist # nvidia-docker 2.0 @@ -37,9 +38,11 @@ COPY debian ./debian RUN sed -i "s;@VERSION@;${PKG_VERS};" $DIST_DIR/nvidia-docker RUN sed -i "s;@TOOLKIT_VERSION@;${TOOLKIT_VERSION};" debian/control && \ - dch --changelog debian/changelog --append "Bump nvidia-container-toolkit dependency to ${TOOLKIT_VERSION}" && \ - dch --changelog debian/changelog -r "" && \ - if [ "$REVISION" != "$(dpkg-parsechangelog --show-field=Version)" ]; then echo "$(dpkg-parsechangelog --show-field=Version)" && exit 1; fi + dch --create --package="${PKG_NAME}" \ + --newversion "${REVISION}" \ + "Bump nvidia-container-toolkit dependency to ${TOOLKIT_VERSION}" && \ + dch -r "" && \ + if [ "$REVISION" != "$(dpkg-parsechangelog --show-field=Version)" ]; then exit 1; fi CMD export DISTRIB="$(lsb_release -cs)" && \ debuild --preserve-env --dpkg-buildpackage-hook='sh debian/prepare' -i -us -uc -b && \ From 779fd0929bbae776976307632b5a33a1636bbccb Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Mon, 8 Nov 2021 15:30:05 +0100 Subject: [PATCH 3/4] Add package name as docker build arg Signed-off-by: Evan Lezar --- docker/Dockerfile.amazonlinux | 6 ++++-- docker/Dockerfile.centos | 4 +++- docker/Dockerfile.debian | 3 ++- docker/Dockerfile.opensuse-leap | 6 ++++-- docker/Dockerfile.ubuntu | 3 ++- docker/docker.mk | 1 + 6 files changed, 16 insertions(+), 7 deletions(-) diff --git a/docker/Dockerfile.amazonlinux b/docker/Dockerfile.amazonlinux index 1970575c..ca3b2de3 100644 --- a/docker/Dockerfile.amazonlinux +++ b/docker/Dockerfile.amazonlinux @@ -7,18 +7,20 @@ RUN yum install -y \ rm -rf /var/cache/yum/* # packaging +ARG PKG_NAME ARG PKG_VERS ARG PKG_REV ARG TOOLKIT_VERSION ARG DOCKER_VERSION +ENV PKG_NAME "${PKG_NAME}" ENV VERSION $PKG_VERS ENV RELEASE $PKG_REV ENV DOCKER_VERSION $DOCKER_VERSION ENV TOOLKIT_VERSION $TOOLKIT_VERSION # output directory -ENV DIST_DIR=/tmp/nvidia-docker2-$PKG_VERS/SOURCES +ENV DIST_DIR=/tmp/${PKG_NAME}-$PKG_VERS/SOURCES RUN mkdir -p $DIST_DIR /dist COPY nvidia-docker $DIST_DIR @@ -35,5 +37,5 @@ CMD rpmbuild --clean -bb \ -D "release $RELEASE" \ -D "docker_version $DOCKER_VERSION" \ -D "toolkit_version $TOOLKIT_VERSION" \ - SPECS/nvidia-docker2.spec && \ + SPECS/${PKG_NAME}.spec && \ mv RPMS/noarch/*.rpm /dist diff --git a/docker/Dockerfile.centos b/docker/Dockerfile.centos index 1970575c..964eef59 100644 --- a/docker/Dockerfile.centos +++ b/docker/Dockerfile.centos @@ -7,18 +7,20 @@ RUN yum install -y \ rm -rf /var/cache/yum/* # packaging +ARG PKG_NAME ARG PKG_VERS ARG PKG_REV ARG TOOLKIT_VERSION ARG DOCKER_VERSION +ENV PKG_NAME "${PKG_NAME}" ENV VERSION $PKG_VERS ENV RELEASE $PKG_REV ENV DOCKER_VERSION $DOCKER_VERSION ENV TOOLKIT_VERSION $TOOLKIT_VERSION # output directory -ENV DIST_DIR=/tmp/nvidia-docker2-$PKG_VERS/SOURCES +ENV DIST_DIR=/tmp/${PKG_NAME}-$PKG_VERS/SOURCES RUN mkdir -p $DIST_DIR /dist COPY nvidia-docker $DIST_DIR diff --git a/docker/Dockerfile.debian b/docker/Dockerfile.debian index b5677afc..9656770a 100644 --- a/docker/Dockerfile.debian +++ b/docker/Dockerfile.debian @@ -11,6 +11,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ rm -rf /var/lib/apt/lists/* # packaging +ARG PKG_NAME ARG PKG_VERS ARG PKG_REV ARG TOOLKIT_VERSION @@ -18,7 +19,7 @@ ARG DOCKER_VERSION ENV DEBFULLNAME "NVIDIA CORPORATION" ENV DEBEMAIL "cudatools@nvidia.com" -ENV PKG_NAME "nvidia-docker2" +ENV PKG_NAME "${PKG_NAME}" ENV REVISION "$PKG_VERS-$PKG_REV" ENV DOCKER_VERSION $DOCKER_VERSION ENV TOOLKIT_VERSION $TOOLKIT_VERSION diff --git a/docker/Dockerfile.opensuse-leap b/docker/Dockerfile.opensuse-leap index 3420ad41..8309dcac 100644 --- a/docker/Dockerfile.opensuse-leap +++ b/docker/Dockerfile.opensuse-leap @@ -7,18 +7,20 @@ RUN zypper install -y \ rm -rf /var/cache/zypp/* # packaging +ARG PKG_NAME ARG PKG_VERS ARG PKG_REV ARG TOOLKIT_VERSION ARG DOCKER_VERSION +ENV PKG_NAME "${PKG_NAME}" ENV VERSION $PKG_VERS ENV RELEASE $PKG_REV ENV DOCKER_VERSION $DOCKER_VERSION ENV TOOLKIT_VERSION $TOOLKIT_VERSION # output directory -ENV DIST_DIR=/tmp/nvidia-docker2-$PKG_VERS/SOURCES +ENV DIST_DIR=/tmp/${PKG_NAME}-$PKG_VERS/SOURCES RUN mkdir -p $DIST_DIR /dist COPY nvidia-docker $DIST_DIR @@ -35,5 +37,5 @@ CMD rpmbuild --clean -bb \ -D "release $RELEASE" \ -D "docker_version $DOCKER_VERSION" \ -D "toolkit_version $TOOLKIT_VERSION" \ - SPECS/nvidia-docker2.spec && \ + SPECS/${PKG_NAME}.spec && \ mv RPMS/noarch/*.rpm /dist diff --git a/docker/Dockerfile.ubuntu b/docker/Dockerfile.ubuntu index bd48fbb3..9e216651 100644 --- a/docker/Dockerfile.ubuntu +++ b/docker/Dockerfile.ubuntu @@ -12,6 +12,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ rm -rf /var/lib/apt/lists/* # packaging +ARG PKG_NAME ARG PKG_VERS ARG PKG_REV ARG TOOLKIT_VERSION @@ -19,7 +20,7 @@ ARG DOCKER_VERSION ENV DEBFULLNAME "NVIDIA CORPORATION" ENV DEBEMAIL "cudatools@nvidia.com" -ENV PKG_NAME "nvidia-docker2" +ENV PKG_NAME "${PKG_NAME}" ENV REVISION "$PKG_VERS-$PKG_REV" ENV DOCKER_VERSION $DOCKER_VERSION ENV TOOLKIT_VERSION $TOOLKIT_VERSION diff --git a/docker/docker.mk b/docker/docker.mk index 1323b221..065798dc 100644 --- a/docker/docker.mk +++ b/docker/docker.mk @@ -157,6 +157,7 @@ docker-build-%: --build-arg BASEIMAGE="$(BASEIMAGE)" \ --build-arg DOCKER_VERSION="$(DOCKER_VERSION)" \ --build-arg TOOLKIT_VERSION="$(MIN_TOOLKIT_PKG_VERSION)" \ + --build-arg PKG_NAME="$(LIB_NAME)" \ --build-arg PKG_VERS="$(LIB_VERSION)" \ --build-arg PKG_REV="$(PKG_REV)" \ --tag $(BUILDIMAGE) \ From 8a2d09b92f7c465e82a3c9ebbfb6100834cbc50c Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Mon, 8 Nov 2021 17:04:43 +0100 Subject: [PATCH 4/4] Add support for specifying docker platform args Signed-off-by: Evan Lezar --- docker/docker.mk | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/docker/docker.mk b/docker/docker.mk index 065798dc..23ce01cc 100644 --- a/docker/docker.mk +++ b/docker/docker.mk @@ -148,11 +148,18 @@ RPM_TOOLKIT_REV := $(if $(TOOLKIT_TAG),0.1.$(TOOLKIT_TAG),1) --opensuse-leap%: DOCKER_VERSION := docker >= 18.09.1_ce --rhel%: DOCKER_VERSION := docker-ce >= 18.06.3.ce-3.el7 +# Depending on the docker version we may have to add the platform args to the +# build and run commands +PLATFORM_ARGS ?= --platform=linux/$(ARCH) +ifneq ($(strip $(ADD_DOCKER_PLATFORM_ARGS)),) +DOCKER_PLATFORM_ARGS = $(PLATFORM_ARGS) +endif + docker-build-%: @echo "Building for $(TARGET_PLATFORM)" - docker pull --platform=linux/$(ARCH) $(BASEIMAGE) + docker pull $(PLATFORM_ARGS) $(BASEIMAGE) DOCKER_BUILDKIT=1 \ - $(DOCKER) build \ + $(DOCKER) build $(DOCKER_PLATFORM_ARGS) \ --progress=plain \ --build-arg BASEIMAGE="$(BASEIMAGE)" \ --build-arg DOCKER_VERSION="$(DOCKER_VERSION)" \ @@ -162,7 +169,7 @@ docker-build-%: --build-arg PKG_REV="$(PKG_REV)" \ --tag $(BUILDIMAGE) \ --file $(DOCKERFILE) . - $(DOCKER) run \ + $(DOCKER) run $(DOCKER_PLATFORM_ARGS) \ -e DISTRIB \ -e SECTION \ -v $(ARTIFACTS_DIR):/dist \