mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-22 00:08:11 +00:00
Merge branch 'CNT-2170/multi-arch' into 'master'
Use buildx and regctl to publish multi-arch images See merge request nvidia/container-toolkit/container-toolkit!103
This commit is contained in:
commit
b0bb7b46e4
@ -20,6 +20,7 @@ default:
|
|||||||
variables:
|
variables:
|
||||||
GIT_SUBMODULE_STRATEGY: recursive
|
GIT_SUBMODULE_STRATEGY: recursive
|
||||||
BUILDIMAGE: "${CI_REGISTRY_IMAGE}/build:${CI_COMMIT_SHORT_SHA}"
|
BUILDIMAGE: "${CI_REGISTRY_IMAGE}/build:${CI_COMMIT_SHORT_SHA}"
|
||||||
|
BUILD_MULTI_ARCH_IMAGES: "true"
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- image
|
- image
|
||||||
@ -96,6 +97,15 @@ stages:
|
|||||||
variables:
|
variables:
|
||||||
ARCH: x86_64
|
ARCH: x86_64
|
||||||
|
|
||||||
|
# Define the platform targets
|
||||||
|
.platform-amd64:
|
||||||
|
variables:
|
||||||
|
PLATFORM: linux/amd64
|
||||||
|
|
||||||
|
.platform-arm64:
|
||||||
|
variables:
|
||||||
|
PLATFORM: linux/arm64
|
||||||
|
|
||||||
# Define test helpers
|
# Define test helpers
|
||||||
.integration:
|
.integration:
|
||||||
stage: test
|
stage: test
|
||||||
@ -117,20 +127,30 @@ test-packaging:
|
|||||||
needs:
|
needs:
|
||||||
- image-packaging
|
- image-packaging
|
||||||
|
|
||||||
|
# Download the regctl binary for use in the release steps
|
||||||
|
.regctl-setup:
|
||||||
|
before_script:
|
||||||
|
- export REGCTL_VERSION=v0.3.10
|
||||||
|
- apk add --no-cache curl
|
||||||
|
- mkdir -p bin
|
||||||
|
- curl -sSLo bin/regctl https://github.com/regclient/regclient/releases/download/${REGCTL_VERSION}/regctl-linux-amd64
|
||||||
|
- chmod a+x bin/regctl
|
||||||
|
- export PATH=$(pwd)/bin:${PATH}
|
||||||
|
|
||||||
# .release forms the base of the deployment jobs which push images to the CI registry.
|
# .release forms the base of the deployment jobs which push images to the CI registry.
|
||||||
# This is extended with the version to be deployed (e.g. the SHA or TAG) and the
|
# This is extended with the version to be deployed (e.g. the SHA or TAG) and the
|
||||||
# target os.
|
# target os.
|
||||||
.release:
|
.release:
|
||||||
stage:
|
stage: release
|
||||||
release
|
|
||||||
variables:
|
variables:
|
||||||
# Define the source image for the release
|
# Define the source image for the release
|
||||||
IMAGE_NAME: "${CI_REGISTRY_IMAGE}/container-toolkit"
|
IMAGE_NAME: "${CI_REGISTRY_IMAGE}/container-toolkit"
|
||||||
VERSION: "${CI_COMMIT_SHORT_SHA}"
|
VERSION: "${CI_COMMIT_SHORT_SHA}"
|
||||||
# OUT_IMAGE_VERSION is overridden for external releases
|
# OUT_IMAGE_VERSION is overridden for external releases
|
||||||
OUT_IMAGE_VERSION: "${CI_COMMIT_SHORT_SHA}"
|
OUT_IMAGE_VERSION: "${CI_COMMIT_SHORT_SHA}"
|
||||||
stage: release
|
|
||||||
before_script:
|
before_script:
|
||||||
|
- !reference [.regctl-setup, before_script]
|
||||||
|
|
||||||
# We ensure that the OUT_IMAGE_VERSION is set
|
# We ensure that the OUT_IMAGE_VERSION is set
|
||||||
- 'echo Version: ${OUT_IMAGE_VERSION} ; [[ -n "${OUT_IMAGE_VERSION}" ]] || exit 1'
|
- 'echo Version: ${OUT_IMAGE_VERSION} ; [[ -n "${OUT_IMAGE_VERSION}" ]] || exit 1'
|
||||||
|
|
||||||
@ -138,16 +158,16 @@ test-packaging:
|
|||||||
# need to tag the image.
|
# need to tag the image.
|
||||||
# Note: a leading 'v' is stripped from the version if present
|
# Note: a leading 'v' is stripped from the version if present
|
||||||
- apk add --no-cache make bash
|
- apk add --no-cache make bash
|
||||||
- 'echo "Logging in to CI registry ${CI_REGISTRY}"'
|
|
||||||
- docker login -u "${CI_REGISTRY_USER}" -p "${CI_REGISTRY_PASSWORD}" "${CI_REGISTRY}"
|
|
||||||
- docker pull "${IMAGE_NAME}:${VERSION}-${DIST}"
|
|
||||||
script:
|
script:
|
||||||
- docker tag "${IMAGE_NAME}:${VERSION}-${DIST}" "${OUT_IMAGE_NAME}:${OUT_IMAGE_VERSION}-${DIST}"
|
|
||||||
# Log in to the "output" registry, tag the image and push the image
|
# Log in to the "output" registry, tag the image and push the image
|
||||||
- 'echo "Logging in to output registry ${OUT_REGISTRY}"'
|
- 'echo "Logging in to CI registry ${CI_REGISTRY}"'
|
||||||
- docker logout
|
- regctl registry login "${CI_REGISTRY}" -u "${CI_REGISTRY_USER}" -p "${CI_REGISTRY_PASSWORD}"
|
||||||
- docker login -u "${OUT_REGISTRY_USER}" -p "${OUT_REGISTRY_TOKEN}" "${OUT_REGISTRY}"
|
- '[ ${CI_REGISTRY} = ${OUT_REGISTRY} ] || echo "Logging in to output registry ${OUT_REGISTRY}"'
|
||||||
- make IMAGE_NAME=${OUT_IMAGE_NAME} VERSION=${OUT_IMAGE_VERSION} -f build/container/Makefile push-${DIST}
|
- '[ ${CI_REGISTRY} = ${OUT_REGISTRY} ] || regctl registry login "${OUT_REGISTRY}" -u "${OUT_REGISTRY_USER}" -p "${OUT_REGISTRY_TOKEN}"'
|
||||||
|
|
||||||
|
# Since OUT_IMAGE_NAME and OUT_IMAGE_VERSION are set, this will push the CI image to the
|
||||||
|
# Target
|
||||||
|
- make -f build/container/Makefile push-${DIST}
|
||||||
|
|
||||||
# Define a staging release step that pushes an image to an internal "staging" repository
|
# Define a staging release step that pushes an image to an internal "staging" repository
|
||||||
# This is triggered for all pipelines (i.e. not only tags) to test the pipeline steps
|
# This is triggered for all pipelines (i.e. not only tags) to test the pipeline steps
|
||||||
|
@ -194,19 +194,33 @@ package-ubuntu18.04-ppc64le:
|
|||||||
- .dist-ubuntu18.04
|
- .dist-ubuntu18.04
|
||||||
- .arch-ppc64le
|
- .arch-ppc64le
|
||||||
|
|
||||||
|
.buildx-setup:
|
||||||
|
before_script:
|
||||||
|
- export BUILDX_VERSION=v0.6.3
|
||||||
|
- apk add --no-cache curl
|
||||||
|
- mkdir -p ~/.docker/cli-plugins
|
||||||
|
- curl -sSLo ~/.docker/cli-plugins/docker-buildx "https://github.com/docker/buildx/releases/download/${BUILDX_VERSION}/buildx-${BUILDX_VERSION}.linux-amd64"
|
||||||
|
- chmod a+x ~/.docker/cli-plugins/docker-buildx
|
||||||
|
|
||||||
|
- docker buildx create --use --platform=linux/amd64,linux/arm64
|
||||||
|
|
||||||
|
- '[[ -n "${SKIP_QEMU_SETUP}" ]] || docker run --rm --privileged multiarch/qemu-user-static --reset -p yes'
|
||||||
|
|
||||||
# Define the image build targets
|
# Define the image build targets
|
||||||
.image-build:
|
.image-build:
|
||||||
stage: image-build
|
stage: image-build
|
||||||
variables:
|
variables:
|
||||||
IMAGE_NAME: "${CI_REGISTRY_IMAGE}/container-toolkit"
|
IMAGE_NAME: "${CI_REGISTRY_IMAGE}/container-toolkit"
|
||||||
VERSION: "${CI_COMMIT_SHORT_SHA}"
|
VERSION: "${CI_COMMIT_SHORT_SHA}"
|
||||||
|
PUSH_ON_BUILD: "true"
|
||||||
before_script:
|
before_script:
|
||||||
|
- !reference [.buildx-setup, before_script]
|
||||||
|
|
||||||
- apk add --no-cache bash make
|
- apk add --no-cache bash make
|
||||||
- 'echo "Logging in to CI registry ${CI_REGISTRY}"'
|
- 'echo "Logging in to CI registry ${CI_REGISTRY}"'
|
||||||
- docker login -u "${CI_REGISTRY_USER}" -p "${CI_REGISTRY_PASSWORD}" "${CI_REGISTRY}"
|
- docker login -u "${CI_REGISTRY_USER}" -p "${CI_REGISTRY_PASSWORD}" "${CI_REGISTRY}"
|
||||||
script:
|
script:
|
||||||
- make -f build/container/Makefile build-${DIST}
|
- make -f build/container/Makefile build-${DIST}
|
||||||
- make -f build/container/Makefile push-${DIST}
|
|
||||||
|
|
||||||
image-centos7:
|
image-centos7:
|
||||||
extends:
|
extends:
|
||||||
@ -233,9 +247,10 @@ image-ubi8:
|
|||||||
- .package-artifacts
|
- .package-artifacts
|
||||||
- .dist-ubi8
|
- .dist-ubi8
|
||||||
needs:
|
needs:
|
||||||
# Note: The ubi8 image currently uses the centos7 packages
|
# Note: The ubi8 image uses the centos8 packages
|
||||||
- package-centos7-ppc64le
|
- package-centos8-aarch64
|
||||||
- package-centos7-x86_64
|
- package-centos8-x86_64
|
||||||
|
- package-centos8-ppc64le
|
||||||
|
|
||||||
image-ubuntu18.04:
|
image-ubuntu18.04:
|
||||||
extends:
|
extends:
|
||||||
|
@ -46,6 +46,7 @@ variables:
|
|||||||
OUT_REGISTRY_TOKEN: "${CI_REGISTRY_PASSWORD}"
|
OUT_REGISTRY_TOKEN: "${CI_REGISTRY_PASSWORD}"
|
||||||
OUT_REGISTRY: "${CI_REGISTRY}"
|
OUT_REGISTRY: "${CI_REGISTRY}"
|
||||||
OUT_IMAGE_NAME: "${CI_REGISTRY_IMAGE}/container-toolkit"
|
OUT_IMAGE_NAME: "${CI_REGISTRY_IMAGE}/container-toolkit"
|
||||||
|
PUSH_MULTIPLE_TAGS: "false"
|
||||||
# We delay the job start to allow the public pipeline to generate the required images.
|
# We delay the job start to allow the public pipeline to generate the required images.
|
||||||
when: delayed
|
when: delayed
|
||||||
start_in: 30 minutes
|
start_in: 30 minutes
|
||||||
@ -56,13 +57,13 @@ variables:
|
|||||||
- job_execution_timeout
|
- job_execution_timeout
|
||||||
- stuck_or_timeout_failure
|
- stuck_or_timeout_failure
|
||||||
before_script:
|
before_script:
|
||||||
|
- !reference [.regctl-setup, before_script]
|
||||||
|
- apk add --no-cache make bash
|
||||||
- >
|
- >
|
||||||
docker pull ${IN_REGISTRY}/${IN_IMAGE_NAME}:${IN_VERSION}-${DIST} > /dev/null && echo "${IN_REGISTRY}/${IN_IMAGE_NAME}:${IN_VERSION}-${DIST}" || ( echo "${IN_REGISTRY}/${IN_IMAGE_NAME}:${IN_VERSION}-${DIST} does not exist" && sleep infinity )
|
regctl manifest get ${IN_REGISTRY}/${IN_IMAGE_NAME}:${IN_VERSION}-${DIST} --list > /dev/null && echo "${IN_REGISTRY}/${IN_IMAGE_NAME}:${IN_VERSION}-${DIST}" || ( echo "${IN_REGISTRY}/${IN_IMAGE_NAME}:${IN_VERSION}-${DIST} does not exist" && sleep infinity )
|
||||||
script:
|
script:
|
||||||
- docker pull ${IN_REGISTRY}/${IN_IMAGE_NAME}:${IN_VERSION}-${DIST}
|
- regctl registry login "${OUT_REGISTRY}" -u "${OUT_REGISTRY_USER}" -p "${OUT_REGISTRY_TOKEN}"
|
||||||
- docker tag ${IN_REGISTRY}/${IN_IMAGE_NAME}:${IN_VERSION}-${DIST} ${OUT_IMAGE_NAME}:${CI_COMMIT_SHORT_SHA}-${DIST}
|
- make -f build/container/Makefile IMAGE=${IN_REGISTRY}/${IN_IMAGE_NAME}:${IN_VERSION}-${DIST} OUT_IMAGE=${OUT_IMAGE_NAME}:${CI_COMMIT_SHORT_SHA}-${DIST} push-${DIST}
|
||||||
- docker login -u "${OUT_REGISTRY_USER}" -p "${OUT_REGISTRY_TOKEN}" "${OUT_REGISTRY}"
|
|
||||||
- docker push ${OUT_IMAGE_NAME}:${CI_COMMIT_SHORT_SHA}-${DIST}
|
|
||||||
|
|
||||||
image-centos7:
|
image-centos7:
|
||||||
extends:
|
extends:
|
||||||
@ -112,7 +113,7 @@ image-packaging:
|
|||||||
before_script:
|
before_script:
|
||||||
- docker login -u "${CI_REGISTRY_USER}" -p "${CI_REGISTRY_PASSWORD}" "${CI_REGISTRY}"
|
- docker login -u "${CI_REGISTRY_USER}" -p "${CI_REGISTRY_PASSWORD}" "${CI_REGISTRY}"
|
||||||
# TODO: We should specify the architecture here and scan all architectures
|
# TODO: We should specify the architecture here and scan all architectures
|
||||||
- docker pull "${IMAGE}"
|
- docker pull --platform="${PLATFORM}" "${IMAGE}"
|
||||||
- docker save "${IMAGE}" -o "${IMAGE_ARCHIVE}"
|
- docker save "${IMAGE}" -o "${IMAGE_ARCHIVE}"
|
||||||
- AuthHeader=$(echo -n $SSA_CLIENT_ID:$SSA_CLIENT_SECRET | base64 -w0)
|
- AuthHeader=$(echo -n $SSA_CLIENT_ID:$SSA_CLIENT_SECRET | base64 -w0)
|
||||||
- >
|
- >
|
||||||
@ -131,34 +132,74 @@ image-packaging:
|
|||||||
- policy_evaluation.json
|
- policy_evaluation.json
|
||||||
|
|
||||||
# Define the scan targets
|
# Define the scan targets
|
||||||
scan-centos7:
|
scan-centos7-amd64:
|
||||||
extends:
|
extends:
|
||||||
- .scan
|
- .scan
|
||||||
- .dist-centos7
|
- .dist-centos7
|
||||||
|
- .platform-amd64
|
||||||
needs:
|
needs:
|
||||||
- image-centos7
|
- image-centos7
|
||||||
|
|
||||||
scan-centos8:
|
scan-centos7-arm64:
|
||||||
|
extends:
|
||||||
|
- .scan
|
||||||
|
- .dist-centos7
|
||||||
|
- .platform-arm64
|
||||||
|
needs:
|
||||||
|
- image-centos7
|
||||||
|
- scan-centos7-amd64
|
||||||
|
|
||||||
|
scan-centos8-amd64:
|
||||||
extends:
|
extends:
|
||||||
- .scan
|
- .scan
|
||||||
- .dist-centos8
|
- .dist-centos8
|
||||||
|
- .platform-amd64
|
||||||
needs:
|
needs:
|
||||||
- image-centos8
|
- image-centos8
|
||||||
|
|
||||||
scan-ubuntu18.04:
|
scan-centos8-arm64:
|
||||||
|
extends:
|
||||||
|
- .scan
|
||||||
|
- .dist-centos8
|
||||||
|
- .platform-arm64
|
||||||
|
needs:
|
||||||
|
- image-centos8
|
||||||
|
- scan-centos8-amd64
|
||||||
|
|
||||||
|
scan-ubuntu18.04-amd64:
|
||||||
extends:
|
extends:
|
||||||
- .scan
|
- .scan
|
||||||
- .dist-ubuntu18.04
|
- .dist-ubuntu18.04
|
||||||
|
- .platform-amd64
|
||||||
needs:
|
needs:
|
||||||
- image-ubuntu18.04
|
- image-ubuntu18.04
|
||||||
|
|
||||||
scan-ubi8:
|
scan-ubuntu18.04-arm64:
|
||||||
|
extends:
|
||||||
|
- .scan
|
||||||
|
- .dist-ubuntu18.04
|
||||||
|
- .platform-arm64
|
||||||
|
needs:
|
||||||
|
- image-ubuntu18.04
|
||||||
|
- scan-ubuntu18.04-amd64
|
||||||
|
|
||||||
|
scan-ubi8-amd64:
|
||||||
extends:
|
extends:
|
||||||
- .scan
|
- .scan
|
||||||
- .dist-ubi8
|
- .dist-ubi8
|
||||||
|
- .platform-amd64
|
||||||
needs:
|
needs:
|
||||||
- image-ubi8
|
- image-ubi8
|
||||||
|
|
||||||
|
scan-ubi8-arm64:
|
||||||
|
extends:
|
||||||
|
- .scan
|
||||||
|
- .dist-ubi8
|
||||||
|
- .platform-arm64
|
||||||
|
needs:
|
||||||
|
- image-ubi8
|
||||||
|
- scan-ubi8-amd64
|
||||||
|
|
||||||
# Define external release helpers
|
# Define external release helpers
|
||||||
.release:ngc:
|
.release:ngc:
|
||||||
extends:
|
extends:
|
||||||
|
@ -63,8 +63,10 @@ COPY ${ARTIFACTS_ROOT}/${PACKAGE_DIST} /artifacts/packages/${PACKAGE_DIST}
|
|||||||
WORKDIR /artifacts/packages
|
WORKDIR /artifacts/packages
|
||||||
|
|
||||||
ARG PACKAGE_VERSION
|
ARG PACKAGE_VERSION
|
||||||
ARG PACKAGE_ARCH
|
ARG TARGETARCH
|
||||||
RUN yum localinstall -y \
|
ENV PACKAGE_ARCH ${TARGETARCH}
|
||||||
|
RUN PACKAGE_ARCH=${PACKAGE_ARCH/amd64/x86_64} && PACKAGE_ARCH=${PACKAGE_ARCH/arm64/aarch64} && \
|
||||||
|
yum localinstall -y \
|
||||||
${PACKAGE_DIST}/${PACKAGE_ARCH}/libnvidia-container1-${PACKAGE_VERSION}*.rpm \
|
${PACKAGE_DIST}/${PACKAGE_ARCH}/libnvidia-container1-${PACKAGE_VERSION}*.rpm \
|
||||||
${PACKAGE_DIST}/${PACKAGE_ARCH}/libnvidia-container-tools-${PACKAGE_VERSION}*.rpm \
|
${PACKAGE_DIST}/${PACKAGE_ARCH}/libnvidia-container-tools-${PACKAGE_VERSION}*.rpm \
|
||||||
${PACKAGE_DIST}/${PACKAGE_ARCH}/nvidia-container-toolkit-${PACKAGE_VERSION}*.rpm
|
${PACKAGE_DIST}/${PACKAGE_ARCH}/nvidia-container-toolkit-${PACKAGE_VERSION}*.rpm
|
||||||
|
@ -45,6 +45,7 @@ FROM nvidia/cuda:${CUDA_VERSION}-base-${BASE_DIST}
|
|||||||
ARG DEBIAN_FRONTEND=noninteractive
|
ARG DEBIAN_FRONTEND=noninteractive
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
libcap2 \
|
libcap2 \
|
||||||
|
curl \
|
||||||
&& \
|
&& \
|
||||||
rm -rf /var/lib/apt/lists/*
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
@ -59,7 +60,17 @@ COPY ${ARTIFACTS_ROOT}/${PACKAGE_DIST} /artifacts/packages/${PACKAGE_DIST}
|
|||||||
WORKDIR /artifacts/packages
|
WORKDIR /artifacts/packages
|
||||||
|
|
||||||
ARG PACKAGE_VERSION
|
ARG PACKAGE_VERSION
|
||||||
ARG PACKAGE_ARCH
|
ARG TARGETARCH
|
||||||
|
ENV PACKAGE_ARCH ${TARGETARCH}
|
||||||
|
|
||||||
|
ARG LIBNVIDIA_CONTAINER_REPO="https://nvidia.github.io/libnvidia-container"
|
||||||
|
ARG LIBNVIDIA_CONTAINER0_VERSION
|
||||||
|
RUN if [ "${PACKAGE_ARCH}" = "arm64" ]; then \
|
||||||
|
curl -L ${LIBNVIDIA_CONTAINER_REPO}/${PACKAGE_DIST}/${PACKAGE_ARCH}/libnvidia-container0_${LIBNVIDIA_CONTAINER0_VERSION}_${PACKAGE_ARCH}.deb \
|
||||||
|
--output ${PACKAGE_DIST}/${PACKAGE_ARCH}/libnvidia-container0_${LIBNVIDIA_CONTAINER0_VERSION}_${PACKAGE_ARCH}.deb && \
|
||||||
|
dpkg -i ${PACKAGE_DIST}/${PACKAGE_ARCH}/libnvidia-container0_${LIBNVIDIA_CONTAINER0_VERSION}_${PACKAGE_ARCH}.deb; \
|
||||||
|
fi
|
||||||
|
|
||||||
RUN dpkg -i \
|
RUN dpkg -i \
|
||||||
${PACKAGE_DIST}/${PACKAGE_ARCH}/libnvidia-container1_${PACKAGE_VERSION}*.deb \
|
${PACKAGE_DIST}/${PACKAGE_ARCH}/libnvidia-container1_${PACKAGE_VERSION}*.deb \
|
||||||
${PACKAGE_DIST}/${PACKAGE_ARCH}/libnvidia-container-tools_${PACKAGE_VERSION}*.deb \
|
${PACKAGE_DIST}/${PACKAGE_ARCH}/libnvidia-container-tools_${PACKAGE_VERSION}*.deb \
|
||||||
|
@ -12,7 +12,14 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
DOCKER ?= docker
|
BUILD_MULTI_ARCH_IMAGES ?= false
|
||||||
|
DOCKER ?= docker
|
||||||
|
|
||||||
|
BUILDX =
|
||||||
|
ifeq ($(BUILD_MULTI_ARCH_IMAGES),true)
|
||||||
|
BUILDX = buildx
|
||||||
|
endif
|
||||||
|
|
||||||
MKDIR ?= mkdir
|
MKDIR ?= mkdir
|
||||||
DIST_DIR ?= $(CURDIR)/dist
|
DIST_DIR ?= $(CURDIR)/dist
|
||||||
|
|
||||||
@ -25,36 +32,47 @@ IMAGE_NAME := $(REGISTRY)/container-toolkit
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
VERSION ?= $(LIB_VERSION)$(if $(LIB_TAG),-$(LIB_TAG))
|
VERSION ?= $(LIB_VERSION)$(if $(LIB_TAG),-$(LIB_TAG))
|
||||||
|
IMAGE_VERSION := $(VERSION)
|
||||||
|
|
||||||
IMAGE_TAG ?= $(VERSION)-$(DIST)
|
IMAGE_TAG ?= $(VERSION)-$(DIST)
|
||||||
IMAGE = $(IMAGE_NAME):$(IMAGE_TAG)
|
IMAGE = $(IMAGE_NAME):$(IMAGE_TAG)
|
||||||
|
|
||||||
|
OUT_IMAGE_NAME ?= $(IMAGE_NAME)
|
||||||
|
OUT_IMAGE_VERSION ?= $(IMAGE_VERSION)
|
||||||
|
OUT_IMAGE_TAG = $(OUT_IMAGE_VERSION)-$(DIST)
|
||||||
|
OUT_IMAGE = $(OUT_IMAGE_NAME):$(OUT_IMAGE_TAG)
|
||||||
|
|
||||||
##### Public rules #####
|
##### Public rules #####
|
||||||
DEFAULT_PUSH_TARGET := ubuntu18.04
|
DEFAULT_PUSH_TARGET := ubuntu18.04
|
||||||
TARGETS := ubuntu20.04 ubuntu18.04 ubi8 centos7 centos8
|
DISTRIBUTIONS := ubuntu20.04 ubuntu18.04 ubi8 centos7 centos8
|
||||||
|
|
||||||
META_TARGETS := packaging
|
META_TARGETS := packaging
|
||||||
|
|
||||||
BUILD_TARGETS := $(patsubst %,build-%,$(TARGETS) $(META_TARGETS))
|
BUILD_TARGETS := $(patsubst %,build-%,$(DISTRIBUTIONS) $(META_TARGETS))
|
||||||
PUSH_TARGETS := $(patsubst %,push-%,$(TARGETS) $(META_TARGETS))
|
PUSH_TARGETS := $(patsubst %,push-%,$(DISTRIBUTIONS) $(META_TARGETS))
|
||||||
TEST_TARGETS := $(patsubst %,test-%, $(TARGETS))
|
TEST_TARGETS := $(patsubst %,test-%, $(DISTRIBUTIONS))
|
||||||
|
|
||||||
.PHONY: $(TARGETS) $(PUSH_TARGETS) $(BUILD_TARGETS) $(TEST_TARGETS)
|
.PHONY: $(DISTRIBUTIONS) $(PUSH_TARGETS) $(BUILD_TARGETS) $(TEST_TARGETS)
|
||||||
|
|
||||||
push-%: DIST = $(*)
|
ifneq ($(BUILD_MULTI_ARCH_IMAGES),true)
|
||||||
$(PUSH_TARGETS): push-%:
|
include $(CURDIR)/build/container/native-only.mk
|
||||||
$(DOCKER) push "$(IMAGE_NAME):$(IMAGE_TAG)"
|
else
|
||||||
|
include $(CURDIR)/build/container/multi-arch.mk
|
||||||
|
endif
|
||||||
|
|
||||||
# For the default push target we also push a short tag equal to the version.
|
# For the default push target we also push a short tag equal to the version.
|
||||||
# We skip this for the development release
|
# We skip this for the development release
|
||||||
DEVEL_RELEASE_IMAGE_VERSION ?= devel
|
DEVEL_RELEASE_IMAGE_VERSION ?= devel
|
||||||
ifneq ($(strip $(VERSION)),$(DEVEL_RELEASE_IMAGE_VERSION))
|
PUSH_MULTIPLE_TAGS ?= true
|
||||||
|
ifeq ($(strip $(OUT_IMAGE_VERSION)),$(DEVEL_RELEASE_IMAGE_VERSION))
|
||||||
|
PUSH_MULTIPLE_TAGS = false
|
||||||
|
endif
|
||||||
|
ifeq ($(PUSH_MULTIPLE_TAGS),true)
|
||||||
push-$(DEFAULT_PUSH_TARGET): push-short
|
push-$(DEFAULT_PUSH_TARGET): push-short
|
||||||
endif
|
endif
|
||||||
push-short:
|
|
||||||
$(DOCKER) tag "$(IMAGE_NAME):$(VERSION)-$(DEFAULT_PUSH_TARGET)" "$(IMAGE_NAME):$(VERSION)"
|
|
||||||
$(DOCKER) push "$(IMAGE_NAME):$(VERSION)"
|
|
||||||
|
|
||||||
|
push-%: DIST = $(*)
|
||||||
|
push-short: DIST = $(DEFAULT_PUSH_TARGET)
|
||||||
|
|
||||||
build-%: DIST = $(*)
|
build-%: DIST = $(*)
|
||||||
build-%: DOCKERFILE = $(CURDIR)/build/container/Dockerfile.$(DOCKERFILE_SUFFIX)
|
build-%: DOCKERFILE = $(CURDIR)/build/container/Dockerfile.$(DOCKERFILE_SUFFIX)
|
||||||
@ -64,16 +82,17 @@ ARTIFACTS_ROOT ?= $(shell realpath --relative-to=$(CURDIR) $(DIST_DIR))
|
|||||||
# Use a generic build target to build the relevant images
|
# Use a generic build target to build the relevant images
|
||||||
$(BUILD_TARGETS): build-%: $(ARTIFACTS_ROOT)
|
$(BUILD_TARGETS): build-%: $(ARTIFACTS_ROOT)
|
||||||
DOCKER_BUILDKIT=1 \
|
DOCKER_BUILDKIT=1 \
|
||||||
$(DOCKER) build --pull \
|
$(DOCKER) $(BUILDX) build --pull \
|
||||||
--platform=linux/amd64 \
|
$(DOCKER_BUILD_OPTIONS) \
|
||||||
|
$(DOCKER_BUILD_PLATFORM_OPTIONS) \
|
||||||
--tag $(IMAGE) \
|
--tag $(IMAGE) \
|
||||||
--build-arg ARTIFACTS_ROOT="$(ARTIFACTS_ROOT)" \
|
--build-arg ARTIFACTS_ROOT="$(ARTIFACTS_ROOT)" \
|
||||||
--build-arg BASE_DIST="$(BASE_DIST)" \
|
--build-arg BASE_DIST="$(BASE_DIST)" \
|
||||||
--build-arg CUDA_VERSION="$(CUDA_VERSION)" \
|
--build-arg CUDA_VERSION="$(CUDA_VERSION)" \
|
||||||
--build-arg GOLANG_VERSION="$(GOLANG_VERSION)" \
|
--build-arg GOLANG_VERSION="$(GOLANG_VERSION)" \
|
||||||
|
--build-arg LIBNVIDIA_CONTAINER0_VERSION="$(LIBNVIDIA_CONTAINER0_DEPENDENCY)" \
|
||||||
--build-arg PACKAGE_DIST="$(PACKAGE_DIST)" \
|
--build-arg PACKAGE_DIST="$(PACKAGE_DIST)" \
|
||||||
--build-arg PACKAGE_VERSION="$(PACKAGE_VERSION)" \
|
--build-arg PACKAGE_VERSION="$(PACKAGE_VERSION)" \
|
||||||
--build-arg PACKAGE_ARCH="$(PACKAGE_ARCH)" \
|
|
||||||
--build-arg VERSION="$(VERSION)" \
|
--build-arg VERSION="$(VERSION)" \
|
||||||
--build-arg CVE_UPDATES="$(CVE_UPDATES)" \
|
--build-arg CVE_UPDATES="$(CVE_UPDATES)" \
|
||||||
-f $(DOCKERFILE) \
|
-f $(DOCKERFILE) \
|
||||||
@ -82,20 +101,17 @@ $(BUILD_TARGETS): build-%: $(ARTIFACTS_ROOT)
|
|||||||
|
|
||||||
build-ubuntu%: BASE_DIST = $(*)
|
build-ubuntu%: BASE_DIST = $(*)
|
||||||
build-ubuntu%: DOCKERFILE_SUFFIX := ubuntu
|
build-ubuntu%: DOCKERFILE_SUFFIX := ubuntu
|
||||||
build-ubuntu%: PACKAGE_ARCH := amd64
|
build-ubuntu%: PACKAGE_DIST = ubuntu18.04
|
||||||
build-ubuntu%: PACKAGE_DIST = $(BASE_DIST)
|
|
||||||
build-ubuntu%: PACKAGE_VERSION := $(LIB_VERSION)$(if $(LIB_TAG),~$(LIB_TAG))
|
build-ubuntu%: PACKAGE_VERSION := $(LIB_VERSION)$(if $(LIB_TAG),~$(LIB_TAG))
|
||||||
|
build-ubuntu%: LIBNVIDIA_CONTAINER0_DEPENDENCY=$(LIBNVIDIA_CONTAINER0_VERSION)
|
||||||
|
|
||||||
# TODO: Update this to use the centos8 packages
|
|
||||||
build-ubi8: BASE_DIST := ubi8
|
build-ubi8: BASE_DIST := ubi8
|
||||||
build-ubi8: DOCKERFILE_SUFFIX := centos
|
build-ubi8: DOCKERFILE_SUFFIX := centos
|
||||||
build-ubi8: PACKAGE_ARCH := x86_64
|
build-ubi8: PACKAGE_DIST = centos8
|
||||||
build-ubi8: PACKAGE_DIST = centos7
|
|
||||||
build-ubi8: PACKAGE_VERSION := $(LIB_VERSION)-$(if $(LIB_TAG),0.1.$(LIB_TAG),1)
|
build-ubi8: PACKAGE_VERSION := $(LIB_VERSION)-$(if $(LIB_TAG),0.1.$(LIB_TAG),1)
|
||||||
|
|
||||||
build-centos%: BASE_DIST = $(*)
|
build-centos%: BASE_DIST = $(*)
|
||||||
build-centos%: DOCKERFILE_SUFFIX := centos
|
build-centos%: DOCKERFILE_SUFFIX := centos
|
||||||
build-centos%: PACKAGE_ARCH := x86_64
|
|
||||||
build-centos%: PACKAGE_DIST = $(BASE_DIST)
|
build-centos%: PACKAGE_DIST = $(BASE_DIST)
|
||||||
build-centos%: PACKAGE_VERSION := $(LIB_VERSION)-$(if $(LIB_TAG),0.1.$(LIB_TAG),1)
|
build-centos%: PACKAGE_VERSION := $(LIB_VERSION)-$(if $(LIB_TAG),0.1.$(LIB_TAG),1)
|
||||||
|
|
||||||
|
34
build/container/multi-arch.mk
Normal file
34
build/container/multi-arch.mk
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
PUSH_ON_BUILD ?= false
|
||||||
|
DOCKER_BUILD_OPTIONS = --output=type=image,push=$(PUSH_ON_BUILD)
|
||||||
|
DOCKER_BUILD_PLATFORM_OPTIONS = --platform=linux/amd64,linux/arm64
|
||||||
|
|
||||||
|
REGCTL ?= regctl
|
||||||
|
$(PUSH_TARGETS): push-%:
|
||||||
|
$(REGCTL) \
|
||||||
|
image copy \
|
||||||
|
$(IMAGE) $(OUT_IMAGE)
|
||||||
|
|
||||||
|
push-short:
|
||||||
|
$(REGCTL) \
|
||||||
|
image copy \
|
||||||
|
$(IMAGE) $(OUT_IMAGE_NAME):$(OUT_IMAGE_VERSION)
|
||||||
|
|
||||||
|
# We only have x86_64 packages for centos7
|
||||||
|
build-centos7: DOCKER_BUILD_PLATFORM_OPTIONS = --platform=linux/amd64
|
||||||
|
|
||||||
|
# We only generate a single image for packaging targets
|
||||||
|
build-packaging: DOCKER_BUILD_PLATFORM_OPTIONS = --platform=linux/amd64
|
23
build/container/native-only.mk
Normal file
23
build/container/native-only.mk
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
DOCKER_BUILD_PLATFORM_OPTIONS = --platform=linux/amd64
|
||||||
|
|
||||||
|
$(PUSH_TARGETS): push-%:
|
||||||
|
$(DOCKER) tag "$(IMAGE)" "$(OUT_IMAGE)"
|
||||||
|
$(DOCKER) push "$(OUT_IMAGE)"
|
||||||
|
|
||||||
|
push-short:
|
||||||
|
$(DOCKER) tag "$(IMAGE_NAME):$(VERSION)-$(DEFAULT_PUSH_TARGET)" "$(OUT_IMAGE_NAME):$(OUT_IMAGE_VERSION)"
|
||||||
|
$(DOCKER) push "$(OUT_IMAGE_NAME):$(OUT_IMAGE_VERSION)"
|
@ -122,6 +122,7 @@ docker-build-%:
|
|||||||
docker pull --platform=linux/$(ARCH) $(BASEIMAGE)
|
docker pull --platform=linux/$(ARCH) $(BASEIMAGE)
|
||||||
DOCKER_BUILDKIT=1 \
|
DOCKER_BUILDKIT=1 \
|
||||||
$(DOCKER) build \
|
$(DOCKER) build \
|
||||||
|
--platform=linux/$(ARCH) \
|
||||||
--progress=plain \
|
--progress=plain \
|
||||||
--build-arg BASEIMAGE="$(BASEIMAGE)" \
|
--build-arg BASEIMAGE="$(BASEIMAGE)" \
|
||||||
--build-arg GOLANG_VERSION="$(GOLANG_VERSION)" \
|
--build-arg GOLANG_VERSION="$(GOLANG_VERSION)" \
|
||||||
@ -131,6 +132,7 @@ docker-build-%:
|
|||||||
--tag $(BUILDIMAGE) \
|
--tag $(BUILDIMAGE) \
|
||||||
--file $(DOCKERFILE) .
|
--file $(DOCKERFILE) .
|
||||||
$(DOCKER) run \
|
$(DOCKER) run \
|
||||||
|
--platform=linux/$(ARCH) \
|
||||||
-e DISTRIB \
|
-e DISTRIB \
|
||||||
-e SECTION \
|
-e SECTION \
|
||||||
-v $(ARTIFACTS_DIR):/dist \
|
-v $(ARTIFACTS_DIR):/dist \
|
||||||
|
@ -422,6 +422,7 @@ func findLibrary(root string, libName string) (string, error) {
|
|||||||
candidateDirs := []string{
|
candidateDirs := []string{
|
||||||
"/usr/lib64",
|
"/usr/lib64",
|
||||||
"/usr/lib/x86_64-linux-gnu",
|
"/usr/lib/x86_64-linux-gnu",
|
||||||
|
"/usr/lib/aarch64-linux-gnu",
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, d := range candidateDirs {
|
for _, d := range candidateDirs {
|
||||||
|
@ -21,5 +21,8 @@ LIB_TAG := rc.1
|
|||||||
NVIDIA_DOCKER_VERSION := 2.10.0
|
NVIDIA_DOCKER_VERSION := 2.10.0
|
||||||
NVIDIA_CONTAINER_RUNTIME_VERSION := 3.9.0
|
NVIDIA_CONTAINER_RUNTIME_VERSION := 3.9.0
|
||||||
|
|
||||||
|
# Specify the expected libnvidia-container0 version for arm64-based ubuntu builds.
|
||||||
|
LIBNVIDIA_CONTAINER0_VERSION := 0.10.0+jetpack
|
||||||
|
|
||||||
CUDA_VERSION := 11.6.0
|
CUDA_VERSION := 11.6.0
|
||||||
GOLANG_VERSION := 1.16.4
|
GOLANG_VERSION := 1.16.4
|
||||||
|
Loading…
Reference in New Issue
Block a user