Add nvidia-docker as folder

Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
Evan Lezar
2023-06-07 13:15:23 +02:00
parent 2464181d2b
commit 69a1a9ef7a
23 changed files with 1294 additions and 1 deletions

View File

@@ -0,0 +1,45 @@
ARG BASEIMAGE
FROM ${BASEIMAGE}
# packaging dependencies
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
dh-make \
fakeroot \
build-essential \
devscripts \
lsb-release && \
rm -rf /var/lib/apt/lists/*
# packaging
ARG PKG_NAME
ARG PKG_VERS
ARG PKG_REV
ARG TOOLKIT_VERSION
ARG DOCKER_VERSION
ENV DEBFULLNAME "NVIDIA CORPORATION"
ENV DEBEMAIL "cudatools@nvidia.com"
ENV PKG_NAME "${PKG_NAME}"
ENV REVISION "$PKG_VERS-$PKG_REV"
ENV DOCKER_VERSION $DOCKER_VERSION
ENV TOOLKIT_VERSION $TOOLKIT_VERSION
ENV SECTION ""
# output directory
ENV DIST_DIR=/tmp/${PKG_NAME}-$PKG_VERS
RUN mkdir -p $DIST_DIR /dist
WORKDIR $DIST_DIR
COPY debian ./debian
RUN sed -i "s;@TOOLKIT_VERSION@;${TOOLKIT_VERSION};" debian/control && \
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 && \
mv /tmp/*.deb /dist

View File

@@ -0,0 +1,36 @@
ARG BASEIMAGE
FROM ${BASEIMAGE}
# packaging dependencies
RUN yum install -y \
rpm-build && \
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/${PKG_NAME}-$PKG_VERS/SOURCES
RUN mkdir -p $DIST_DIR /dist
WORKDIR $DIST_DIR/..
COPY rpm .
CMD rpmbuild --clean -bb \
-D "_topdir $PWD" \
-D "release_date $(date +'%a %b %d %Y')" \
-D "version $VERSION" \
-D "release $RELEASE" \
-D "toolkit_version $TOOLKIT_VERSION" \
SPECS/nvidia-docker2.spec && \
mv RPMS/noarch/*.rpm /dist

View File

@@ -0,0 +1,77 @@
# Copyright (c) 2021, 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.
DOCKER ?= docker
MKDIR ?= mkdir
DIST_DIR ?= $(CURDIR)/dist
# Supported packaging formats
FORMAT_TARGETS := deb rpm
# We add utility targets to support common os-arch combinations by mapping to the required format targets.
DEB_TARGETS := debian10-amd64 ubuntu18.04-amd64 ubuntu18.04-arm64 ubuntu18.04-ppc64le
RPM_TARGETS := amazonlinux2-aarch64 amazonlinux2-x86_64 centos7-x86_64 centos8-aarch64 centos8-ppc64le centos8-x86_64 opensuse-leap15.1-x86_64
$(DEB_TARGETS): %: deb
$(RPM_TARGETS): %: rpm
# Define top-level build targets
docker%: SHELL:=/bin/bash
$(FORMAT_TARGETS): %: --%
# Default variables for all private '--' targets below.
# One private target is defined for each OS we support.
--%: FORMAT = $(*)
--%: BUILDIMAGE = nvidia/$(LIB_NAME)/$(FORMAT)-all
--%: DOCKERFILE = $(CURDIR)/docker/Dockerfile.$(FORMAT)
--%: ARTIFACTS_DIR = $(DIST_DIR)/$(FORMAT)/all
--%: docker-build-%
@
PKG_VERS = $(LIB_VERSION)$(if $(LIB_TAG),~$(LIB_TAG))
PKG_REV = 1
MIN_TOOLKIT_PKG_VERSION = $(TOOLKIT_VERSION)$(if $(TOOLKIT_TAG),~$(TOOLKIT_TAG))-1
--deb: BASEIMAGE := ubuntu:18.04
--rpm: BASEIMAGE := quay.io/centos/centos:stream8
docker-build-%:
@echo "Building $(FORMAT) packages to $(ARTIFACTS_DIR)"
docker pull $(BASEIMAGE)
DOCKER_BUILDKIT=1 \
$(DOCKER) build \
--progress=plain \
--build-arg BASEIMAGE="$(BASEIMAGE)" \
--build-arg TOOLKIT_VERSION="$(MIN_TOOLKIT_PKG_VERSION)" \
--build-arg PKG_NAME="$(LIB_NAME)" \
--build-arg PKG_VERS="$(PKG_VERS)" \
--build-arg PKG_REV="$(PKG_REV)" \
--tag $(BUILDIMAGE) \
--file $(DOCKERFILE) .
$(DOCKER) run \
-e DISTRIB \
-e SECTION \
-v $(ARTIFACTS_DIR):/dist \
$(BUILDIMAGE)
docker-clean:
IMAGES=$$(docker images "nvidia/$(LIB_NAME)/*" --format="{{.ID}}"); \
if [ "$${IMAGES}" != "" ]; then \
docker rmi -f $${IMAGES}; \
fi
distclean:
rm -rf $(DIST_DIR)