From bdfd123b9d9abf277d08817da62ab53f3c863ef3 Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Wed, 10 Aug 2022 14:17:33 +0200 Subject: [PATCH] Switch to single docker file yum-based rpm builds This reuses the docker file for yum-based rpm distros (centos, amazonlinux) instead of maintaining two files with the same contents. Signed-off-by: Evan Lezar --- docker/Dockerfile.amazonlinux | 76 ------------------- .../{Dockerfile.centos => Dockerfile.rpm-yum} | 16 ++++ docker/docker.mk | 7 +- 3 files changed, 21 insertions(+), 78 deletions(-) delete mode 100644 docker/Dockerfile.amazonlinux rename docker/{Dockerfile.centos => Dockerfile.rpm-yum} (76%) diff --git a/docker/Dockerfile.amazonlinux b/docker/Dockerfile.amazonlinux deleted file mode 100644 index 6fd00c1e..00000000 --- a/docker/Dockerfile.amazonlinux +++ /dev/null @@ -1,76 +0,0 @@ -ARG BASEIMAGE -FROM ${BASEIMAGE} - -RUN yum install -y \ - ca-certificates \ - gcc \ - wget \ - git \ - rpm-build \ - make && \ - rm -rf /var/cache/yum/* - -ARG GOLANG_VERSION=0.0.0 -RUN set -eux; \ - \ - arch="$(uname -m)"; \ - case "${arch##*-}" in \ - x86_64 | amd64) ARCH='amd64' ;; \ - ppc64el | ppc64le) ARCH='ppc64le' ;; \ - aarch64) ARCH='arm64' ;; \ - *) echo "unsupported architecture"; exit 1 ;; \ - esac; \ - wget -nv -O - https://storage.googleapis.com/golang/go${GOLANG_VERSION}.linux-${ARCH}.tar.gz \ - | tar -C /usr/local -xz - -ENV GOPATH /go -ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH - -# packaging -ARG PKG_NAME -ARG PKG_VERS -ARG PKG_REV - -ENV VERSION $PKG_VERS -ENV RELEASE $PKG_REV - -# output directory -ENV DIST_DIR=/tmp/nvidia-container-toolkit-$PKG_VERS/SOURCES -RUN mkdir -p $DIST_DIR /dist - -# nvidia-container-toolkit -WORKDIR $GOPATH/src/nvidia-container-toolkit -COPY . . - -ARG GIT_COMMIT -ENV GIT_COMMIT ${GIT_COMMIT} -RUN make PREFIX=${DIST_DIR} cmds - -ARG CONFIG_TOML_SUFFIX -ENV CONFIG_TOML_SUFFIX ${CONFIG_TOML_SUFFIX} -COPY config/config.toml.${CONFIG_TOML_SUFFIX} $DIST_DIR/config.toml - -# Hook for Project Atomic's fork of Docker: https://github.com/projectatomic/docker/tree/docker-1.13.1-rhel#add-dockerhooks-exec-custom-hooks-for-prestartpoststop-containerspatch -# This might not be useful on Amazon Linux, but it's simpler to keep the RHEL -# and Amazon Linux packages identical. -COPY oci-nvidia-hook $DIST_DIR/oci-nvidia-hook - -# Hook for libpod/CRI-O: https://github.com/containers/libpod/blob/v0.8.5/pkg/hooks/docs/oci-hooks.5.md -COPY oci-nvidia-hook.json $DIST_DIR/oci-nvidia-hook.json - -WORKDIR $DIST_DIR/.. -COPY packaging/rpm . - -ARG LIBNVIDIA_CONTAINER_TOOLS_VERSION -ENV LIBNVIDIA_CONTAINER_TOOLS_VERSION ${LIBNVIDIA_CONTAINER_TOOLS_VERSION} - -CMD arch=$(uname -m) && \ - rpmbuild --clean --target=$arch -bb \ - -D "_topdir $PWD" \ - -D "release_date $(date +'%a %b %d %Y')" \ - -D "git_commit ${GIT_COMMIT}" \ - -D "version $VERSION" \ - -D "libnvidia_container_tools_version ${LIBNVIDIA_CONTAINER_TOOLS_VERSION}" \ - -D "release $RELEASE" \ - SPECS/nvidia-container-toolkit.spec && \ - mv RPMS/$arch/*.rpm /dist diff --git a/docker/Dockerfile.centos b/docker/Dockerfile.rpm-yum similarity index 76% rename from docker/Dockerfile.centos rename to docker/Dockerfile.rpm-yum index a64409d9..b4c2ed2f 100644 --- a/docker/Dockerfile.centos +++ b/docker/Dockerfile.rpm-yum @@ -1,3 +1,19 @@ +# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This is the dockerfile for building packages on yum-based RPM systems. + ARG BASEIMAGE FROM ${BASEIMAGE} diff --git a/docker/docker.mk b/docker/docker.mk index cf511afa..c21aa51b 100644 --- a/docker/docker.mk +++ b/docker/docker.mk @@ -14,10 +14,10 @@ # Supported OSs by architecture AMD64_TARGETS := ubuntu20.04 ubuntu18.04 ubuntu16.04 debian10 debian9 -X86_64_TARGETS := centos7 centos8 rhel7 rhel8 amazonlinux2 opensuse-leap15.1 +X86_64_TARGETS := fedora35 centos7 centos8 rhel7 rhel8 amazonlinux2 opensuse-leap15.1 PPC64LE_TARGETS := ubuntu18.04 ubuntu16.04 centos7 centos8 rhel7 rhel8 ARM64_TARGETS := ubuntu20.04 ubuntu18.04 -AARCH64_TARGETS := centos8 rhel8 amazonlinux2 +AARCH64_TARGETS := fedora35 centos8 rhel8 amazonlinux2 # Define top-level build targets docker%: SHELL:=/bin/bash @@ -104,12 +104,14 @@ LIBNVIDIA_CONTAINER_TAG ?= $(LIB_TAG) --centos%: OS := centos --centos%: PKG_REV := $(if $(LIB_TAG),0.1.$(LIB_TAG),1) --centos%: LIBNVIDIA_CONTAINER_TOOLS_VERSION := $(LIBNVIDIA_CONTAINER_VERSION)-$(if $(LIBNVIDIA_CONTAINER_TAG),0.1.$(LIBNVIDIA_CONTAINER_TAG),1) +--centos%: DOCKERFILE = $(CURDIR)/docker/Dockerfile.rpm-yum --centos8%: BASEIMAGE = quay.io/centos/centos:stream8 # private amazonlinux target --amazonlinux%: OS := amazonlinux --amazonlinux%: LIBNVIDIA_CONTAINER_TOOLS_VERSION := $(LIBNVIDIA_CONTAINER_VERSION)-$(if $(LIBNVIDIA_CONTAINER_TAG),0.1.$(LIBNVIDIA_CONTAINER_TAG),1) --amazonlinux%: PKG_REV := $(if $(LIB_TAG),0.1.$(LIB_TAG),1) +--amazonlinux%: DOCKERFILE = $(CURDIR)/docker/Dockerfile.rpm-yum # private opensuse-leap target --opensuse-leap%: OS = opensuse-leap @@ -123,6 +125,7 @@ LIBNVIDIA_CONTAINER_TAG ?= $(LIB_TAG) --rhel%: PKG_REV := $(if $(LIB_TAG),0.1.$(LIB_TAG),1) --rhel%: VERSION = $(patsubst rhel%-$(ARCH),%,$(TARGET_PLATFORM)) --rhel%: ARTIFACTS_DIR = $(DIST_DIR)/rhel$(VERSION)/$(ARCH) +--rhel%: DOCKERFILE = $(CURDIR)/docker/Dockerfile.rpm-yum --rhel8%: BASEIMAGE = quay.io/centos/centos:stream8 # We allow the CONFIG_TOML_SUFFIX to be overridden.