diff --git a/.common-ci.yml b/.common-ci.yml index c252332e..bfd50503 100644 --- a/.common-ci.yml +++ b/.common-ci.yml @@ -34,70 +34,15 @@ stages: - release - build-all -build-dev-image: - stage: image - script: - - apk --no-cache add make bash - - make .build-image - - docker login -u "${CI_REGISTRY_USER}" -p "${CI_REGISTRY_PASSWORD}" "${CI_REGISTRY}" - - make .push-build-image - -.requires-build-image: - image: "${BUILDIMAGE}" - -.go-check: - extends: - - .requires-build-image - stage: go-checks - -fmt: - extends: - - .go-check - script: - - make assert-fmt - -vet: - extends: - - .go-check - script: - - make vet - -lint: - extends: - - .go-check - script: - - make lint - allow_failure: true - -ineffassign: - extends: - - .go-check - script: - - make ineffassign - allow_failure: true - -misspell: - extends: - - .go-check - script: - - make misspell - -go-build: - extends: - - .requires-build-image - stage: go-build - script: - - make build - -unit-tests: - extends: - - .requires-build-image - stage: unit-tests - script: - - make coverage - - # Define the distribution targets +.dist-amazonlinux1: + variables: + DIST: amazonlinux1 + +.dist-amazonlinux2: + variables: + DIST: amazonlinux2 + .dist-centos7: variables: DIST: centos7 @@ -106,14 +51,35 @@ unit-tests: variables: DIST: centos8 +.dist-debian10: + variables: + DIST: debian10 + +.dist-debian9: + variables: + DIST: debian9 + +.dist-opensuse-leap15.1: + variables: + DIST: opensuse-leap15.1 + .dist-ubi8: variables: DIST: ubi8 +.dist-ubuntu16.04: + variables: + DIST: ubuntu16.04 + .dist-ubuntu18.04: variables: DIST: ubuntu18.04 +.dist-packaging: + variables: + DIST: packaging + +# Define architecture targets .arch-aarch64: variables: ARCH: aarch64 @@ -134,121 +100,6 @@ unit-tests: variables: ARCH: x86_64 -# Define the package build helpers -.multi-arch-build: - before_script: - - apk add --no-cache coreutils build-base sed git bash make - - '[[ -n "${SKIP_QEMU_SETUP}" ]] || docker run --rm --privileged multiarch/qemu-user-static --reset -p yes -c yes' - -.package-artifacts: - variables: - ARTIFACTS_NAME: "toolkit-container-${CI_PIPELINE_ID}" - ARTIFACTS_ROOT: "toolkit-container-${CI_PIPELINE_ID}" - DIST_DIR: ${CI_PROJECT_DIR}/${ARTIFACTS_ROOT} - -.package-build: - extends: - - .multi-arch-build - - .package-artifacts - stage: package-build - script: - - ./scripts/release.sh ${DIST}-${ARCH} - - artifacts: - name: ${ARTIFACTS_NAME} - paths: - - ${ARTIFACTS_ROOT} - -# Define the package build targets -package-ubuntu18.04-amd64: - extends: - - .package-build - - .dist-ubuntu18.04 - - .arch-amd64 - -package-ubuntu18.04-arm64: - extends: - - .package-build - - .dist-ubuntu18.04 - - .arch-arm64 - -package-ubuntu18.04-ppc64le: - extends: - - .package-build - - .dist-ubuntu18.04 - - .arch-ppc64le - -package-centos7-x86_64: - extends: - - .package-build - - .dist-centos7 - - .arch-x86_64 - -package-centos8-x86_64: - extends: - - .package-build - - .dist-centos8 - - .arch-x86_64 - -# Define the image build targets -.image-build: - stage: image-build - variables: - IMAGE_NAME: "${CI_REGISTRY_IMAGE}/container-toolkit" - VERSION: "${CI_COMMIT_SHORT_SHA}" - before_script: - - apk add --no-cache bash make - - 'echo "Logging in to CI registry ${CI_REGISTRY}"' - - docker login -u "${CI_REGISTRY_USER}" -p "${CI_REGISTRY_PASSWORD}" "${CI_REGISTRY}" - -image-centos7: - extends: - - .image-build - - .package-artifacts - - .dist-centos7 - needs: - - package-centos7-x86_64 - script: - - make -f build/container/Makefile build-${DIST} - - make -f build/container/Makefile push-${DIST} - -image-centos8: - extends: - - .image-build - - .package-artifacts - - .dist-centos8 - needs: - - package-centos8-x86_64 - script: - - make -f build/container/Makefile build-${DIST} - - make -f build/container/Makefile push-${DIST} - -image-ubi8: - extends: - - .image-build - - .package-artifacts - - .dist-ubi8 - needs: - # Note: The ubi8 image currently uses the centos7 packages - - package-centos7-x86_64 - script: - - make -f build/container/Makefile build-${DIST} - - make -f build/container/Makefile push-${DIST} - -image-ubuntu18.04: - extends: - - .image-build - - .package-artifacts - - .dist-ubuntu18.04 - needs: - - package-ubuntu18.04-amd64 - # TODO: These will be required once we generate multi-arch images - # - package-ubuntu18.04-arm64 - # - package-ubuntu18.04-ppc64le - script: - - make -f build/container/Makefile build-${DIST} - - make -f build/container/Makefile push-${DIST} - # Define test helpers .integration: stage: test @@ -262,62 +113,13 @@ image-ubuntu18.04: script: - make -f build/container/Makefile test-${DIST} -.test:toolkit: - extends: - - .integration - variables: - TEST_CASES: "toolkit" - -.test:docker: - extends: - - .integration - variables: - TEST_CASES: "docker" - -.test:containerd: - # TODO: The containerd tests fail due to issues with SIGHUP. - # Until this is resolved with retry up to twice and allow failure here. - retry: 2 - allow_failure: true - extends: - - .integration - variables: - TEST_CASES: "containerd" - -.test:crio: - extends: - - .integration - variables: - TEST_CASES: "crio" - # Define the test targets -test-toolkit-ubuntu18.04: +test-packaging: extends: - - .test:toolkit - - .dist-ubuntu18.04 + - .integration + - .dist-packaging needs: - - image-ubuntu18.04 - -test-containerd-ubuntu18.04: - extends: - - .test:containerd - - .dist-ubuntu18.04 - needs: - - image-ubuntu18.04 - -test-crio-ubuntu18.04: - extends: - - .test:crio - - .dist-ubuntu18.04 - needs: - - image-ubuntu18.04 - -test-docker-ubuntu18.04: - extends: - - .test:docker - - .dist-ubuntu18.04 - needs: - - image-ubuntu18.04 + - image-packaging # .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 @@ -407,3 +209,10 @@ release:staging-ubuntu18.04: - test-containerd-ubuntu18.04 - test-crio-ubuntu18.04 - test-docker-ubuntu18.04 + +release:staging-packaging: + extends: + - .release:staging + - .dist-packaging + needs: + - test-packaging diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 81d2abfb..f716cae0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -15,6 +15,325 @@ include: - .common-ci.yml +build-dev-image: + stage: image + script: + - apk --no-cache add make bash + - make .build-image + - docker login -u "${CI_REGISTRY_USER}" -p "${CI_REGISTRY_PASSWORD}" "${CI_REGISTRY}" + - make .push-build-image + +.requires-build-image: + image: "${BUILDIMAGE}" + +.go-check: + extends: + - .requires-build-image + stage: go-checks + +fmt: + extends: + - .go-check + script: + - make assert-fmt + +vet: + extends: + - .go-check + script: + - make vet + +lint: + extends: + - .go-check + script: + - make lint + allow_failure: true + +ineffassign: + extends: + - .go-check + script: + - make ineffassign + allow_failure: true + +misspell: + extends: + - .go-check + script: + - make misspell + +go-build: + extends: + - .requires-build-image + stage: go-build + script: + - make build + +unit-tests: + extends: + - .requires-build-image + stage: unit-tests + script: + - make coverage + +# Define the package build helpers +.multi-arch-build: + before_script: + - apk add --no-cache coreutils build-base sed git bash make + - '[[ -n "${SKIP_QEMU_SETUP}" ]] || docker run --rm --privileged multiarch/qemu-user-static --reset -p yes -c yes' + +.package-artifacts: + variables: + ARTIFACTS_NAME: "toolkit-container-${CI_PIPELINE_ID}" + ARTIFACTS_ROOT: "toolkit-container-${CI_PIPELINE_ID}" + DIST_DIR: ${CI_PROJECT_DIR}/${ARTIFACTS_ROOT} + +.package-build: + extends: + - .multi-arch-build + - .package-artifacts + stage: package-build + script: + - ./scripts/release.sh ${DIST}-${ARCH} + + artifacts: + name: ${ARTIFACTS_NAME} + paths: + - ${ARTIFACTS_ROOT} + +# Define the package build targets +package-amazonlinux1-x86_64: + extends: + - .package-build + - .dist-amazonlinux1 + - .arch-x86_64 + +package-amazonlinux2-aarch64: + extends: + - .package-build + - .dist-amazonlinux2 + - .arch-aarch64 + +package-amazonlinux2-x86_64: + extends: + - .package-build + - .dist-amazonlinux2 + - .arch-x86_64 + +package-centos7-ppc64le: + extends: + - .package-build + - .dist-centos7 + - .arch-ppc64le + +package-centos7-x86_64: + extends: + - .package-build + - .dist-centos7 + - .arch-x86_64 + +package-centos8-aarch64: + extends: + - .package-build + - .dist-centos8 + - .arch-aarch64 + +package-centos8-ppc64le: + extends: + - .package-build + - .dist-centos8 + - .arch-ppc64le + +package-centos8-x86_64: + extends: + - .package-build + - .dist-centos8 + - .arch-x86_64 + +package-debian10-amd64: + extends: + - .package-build + - .dist-debian10 + - .arch-amd64 + +package-debian9-amd64: + extends: + - .package-build + - .dist-debian9 + - .arch-amd64 + +package-opensuse-leap15.1-x86_64: + extends: + - .package-build + - .dist-opensuse-leap15.1 + - .arch-x86_64 + +package-ubuntu16.04-amd64: + extends: + - .package-build + - .dist-ubuntu16.04 + - .arch-amd64 + +package-ubuntu16.04-ppc64le: + extends: + - .package-build + - .dist-ubuntu16.04 + - .arch-ppc64le + +package-ubuntu18.04-amd64: + extends: + - .package-build + - .dist-ubuntu18.04 + - .arch-amd64 + +package-ubuntu18.04-arm64: + extends: + - .package-build + - .dist-ubuntu18.04 + - .arch-arm64 + +package-ubuntu18.04-ppc64le: + extends: + - .package-build + - .dist-ubuntu18.04 + - .arch-ppc64le + +# Define the image build targets +.image-build: + stage: image-build + variables: + IMAGE_NAME: "${CI_REGISTRY_IMAGE}/container-toolkit" + VERSION: "${CI_COMMIT_SHORT_SHA}" + before_script: + - apk add --no-cache bash make + - 'echo "Logging in to CI registry ${CI_REGISTRY}"' + - docker login -u "${CI_REGISTRY_USER}" -p "${CI_REGISTRY_PASSWORD}" "${CI_REGISTRY}" + script: + - make -f build/container/Makefile build-${DIST} + - make -f build/container/Makefile push-${DIST} + +image-centos7: + extends: + - .image-build + - .package-artifacts + - .dist-centos7 + needs: + - package-centos7-ppc64le + - package-centos7-x86_64 + +image-centos8: + extends: + - .image-build + - .package-artifacts + - .dist-centos8 + needs: + - package-centos8-aarch64 + - package-centos8-x86_64 + - package-centos8-ppc64le + +image-ubi8: + extends: + - .image-build + - .package-artifacts + - .dist-ubi8 + needs: + # Note: The ubi8 image currently uses the centos7 packages + - package-centos7-ppc64le + - package-centos7-x86_64 + +image-ubuntu18.04: + extends: + - .image-build + - .package-artifacts + - .dist-ubuntu18.04 + needs: + - package-ubuntu18.04-amd64 + - package-ubuntu18.04-arm64 + - package-ubuntu18.04-ppc64le + +# The DIST=packaging target creates an image containing all built packages +image-packaging: + extends: + - .image-build + - .package-artifacts + - .dist-packaging + needs: + - package-amazonlinux1-x86_64 + - package-amazonlinux2-aarch64 + - package-amazonlinux2-x86_64 + - package-centos7-ppc64le + - package-centos7-x86_64 + - package-centos8-aarch64 + - package-centos8-ppc64le + - package-centos8-x86_64 + - package-debian10-amd64 + - package-debian9-amd64 + - package-opensuse-leap15.1-x86_64 + - package-ubuntu16.04-amd64 + - package-ubuntu16.04-ppc64le + - package-ubuntu18.04-amd64 + - package-ubuntu18.04-arm64 + - package-ubuntu18.04-ppc64le + +# Define publish test helpers +.test:toolkit: + extends: + - .integration + variables: + TEST_CASES: "toolkit" + +.test:docker: + extends: + - .integration + variables: + TEST_CASES: "docker" + +.test:containerd: + # TODO: The containerd tests fail due to issues with SIGHUP. + # Until this is resolved with retry up to twice and allow failure here. + retry: 2 + allow_failure: true + extends: + - .integration + variables: + TEST_CASES: "containerd" + +.test:crio: + extends: + - .integration + variables: + TEST_CASES: "crio" + +# Define the test targets +test-toolkit-ubuntu18.04: + extends: + - .test:toolkit + - .dist-ubuntu18.04 + needs: + - image-ubuntu18.04 + +test-containerd-ubuntu18.04: + extends: + - .test:containerd + - .dist-ubuntu18.04 + needs: + - image-ubuntu18.04 + +test-crio-ubuntu18.04: + extends: + - .test:crio + - .dist-ubuntu18.04 + needs: + - image-ubuntu18.04 + +test-docker-ubuntu18.04: + extends: + - .test:docker + - .dist-ubuntu18.04 + needs: + - image-ubuntu18.04 + # build-all jobs build packages for every OS / ARCH combination we support. # # They are run under two conditions: diff --git a/.nvidia-ci.yml b/.nvidia-ci.yml index 83ed0037..09c9a6f0 100644 --- a/.nvidia-ci.yml +++ b/.nvidia-ci.yml @@ -32,6 +32,63 @@ variables: DEVEL_RELEASE_IMAGE_VERSION: "devel" # On the multi-arch builder we don't need the qemu setup. SKIP_QEMU_SETUP: "1" + # Define the public staging registry + STAGING_REGISTRY: registry.gitlab.com/nvidia/container-toolkit/container-toolkit/staging + STAGING_VERSION: ${CI_COMMIT_SHORT_SHA} + +.image-pull: + stage: image-build + variables: + IN_REGISTRY: "${STAGING_REGISTRY}" + IN_IMAGE_NAME: container-toolkit + IN_VERSION: "${STAGING_VERSION}" + OUT_REGISTRY_USER: "${CI_REGISTRY_USER}" + OUT_REGISTRY_TOKEN: "${CI_REGISTRY_PASSWORD}" + OUT_REGISTRY: "${CI_REGISTRY}" + OUT_IMAGE_NAME: "${CI_REGISTRY_IMAGE}/container-toolkit" + # We delay the job start to allow the public pipeline to generate the required images. + when: delayed + start_in: 30 minutes + timeout: 30 minutes + retry: + max: 2 + when: + - job_execution_timeout + - stuck_or_timeout_failure + before_script: + - > + 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 ) + script: + - docker pull ${IN_REGISTRY}/${IN_IMAGE_NAME}:${IN_VERSION}-${DIST} + - docker tag ${IN_REGISTRY}/${IN_IMAGE_NAME}:${IN_VERSION}-${DIST} ${OUT_IMAGE_NAME}:${CI_COMMIT_SHORT_SHA}-${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: + extends: + - .image-pull + - .dist-centos7 + +image-centos8: + extends: + - .image-pull + - .dist-centos8 + +image-ubi8: + extends: + - .image-pull + - .dist-ubi8 + +image-ubuntu18.04: + extends: + - .image-pull + - .dist-ubuntu18.04 + +# The DIST=packaging target creates an image containing all built packages +image-packaging: + extends: + - .image-pull + - .dist-packaging # We skip the integration tests for the internal CI: .integration: @@ -130,6 +187,13 @@ scan-ubi8: # TODO: For now we disable external releases DOCKER: echo +release:staging-ubuntu18.04: + extends: + - .release:staging + - .dist-ubuntu18.04 + needs: + - image-ubuntu18.04 + # Define the external release targets # Release to NGC release:ngc-centos7: diff --git a/build/container/Dockerfile.centos b/build/container/Dockerfile.centos index b47778ec..26b6bf95 100644 --- a/build/container/Dockerfile.centos +++ b/build/container/Dockerfile.centos @@ -46,16 +46,18 @@ ENV NVIDIA_DISABLE_REQUIRE="true" ENV NVIDIA_VISIBLE_DEVICES=all ENV NVIDIA_DRIVER_CAPABILITIES=utility +ARG ARTIFACTS_ROOT +ARG PACKAGE_DIST +COPY ${ARTIFACTS_ROOT}/${PACKAGE_DIST} /artifacts/packages/${PACKAGE_DIST} + WORKDIR /artifacts/packages -ARG ARTIFACTS_DIR -COPY ${ARTIFACTS_DIR}/* /artifacts/packages/ - ARG PACKAGE_VERSION +ARG PACKAGE_ARCH RUN yum localinstall -y \ - libnvidia-container1-${PACKAGE_VERSION}*.rpm \ - libnvidia-container-tools-${PACKAGE_VERSION}*.rpm \ - nvidia-container-toolkit-${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}/nvidia-container-toolkit-${PACKAGE_VERSION}*.rpm WORKDIR /work diff --git a/build/container/Dockerfile.packaging b/build/container/Dockerfile.packaging new file mode 100644 index 00000000..baeee6b4 --- /dev/null +++ b/build/container/Dockerfile.packaging @@ -0,0 +1,29 @@ +# 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. + +ARG BASE_DIST +ARG CUDA_VERSION +ARG GOLANG_VERSION=x.x.x +ARG VERSION="N/A" + +FROM nvidia/cuda:${CUDA_VERSION}-base-${BASE_DIST} + +ENV NVIDIA_CONTAINER_TOOLKIT_VERSION="${VERSION}" + +ARG ARTIFACTS_ROOT +COPY ${ARTIFACTS_ROOT} /artifacts/packages/ + +WORKDIR /artifacts/packages + +COPY ./LICENSE /licenses/LICENSE diff --git a/build/container/Dockerfile.ubuntu b/build/container/Dockerfile.ubuntu index 6cd3bfa1..ff3d30bd 100644 --- a/build/container/Dockerfile.ubuntu +++ b/build/container/Dockerfile.ubuntu @@ -52,16 +52,18 @@ ENV NVIDIA_DISABLE_REQUIRE="true" ENV NVIDIA_VISIBLE_DEVICES=all ENV NVIDIA_DRIVER_CAPABILITIES=utility +ARG ARTIFACTS_ROOT +ARG PACKAGE_DIST +COPY ${ARTIFACTS_ROOT}/${PACKAGE_DIST} /artifacts/packages/${PACKAGE_DIST} + WORKDIR /artifacts/packages -ARG ARTIFACTS_DIR -COPY ${ARTIFACTS_DIR}/* /artifacts/packages/ - ARG PACKAGE_VERSION +ARG PACKAGE_ARCH RUN dpkg -i \ - libnvidia-container1_${PACKAGE_VERSION}*.deb \ - libnvidia-container-tools_${PACKAGE_VERSION}*.deb \ - nvidia-container-toolkit_${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}/nvidia-container-toolkit_${PACKAGE_VERSION}*.deb WORKDIR /work diff --git a/build/container/Makefile b/build/container/Makefile index 4e6fb1ce..c62e5b58 100644 --- a/build/container/Makefile +++ b/build/container/Makefile @@ -33,12 +33,15 @@ IMAGE = $(IMAGE_NAME):$(IMAGE_TAG) DEFAULT_PUSH_TARGET := ubuntu18.04 TARGETS := ubuntu20.04 ubuntu18.04 ubi8 centos7 centos8 -BUILD_TARGETS := $(patsubst %, build-%, $(TARGETS)) -PUSH_TARGETS := $(patsubst %, push-%, $(TARGETS)) -TEST_TARGETS := $(patsubst %, test-%, $(TARGETS)) +META_TARGETS := packaging + +BUILD_TARGETS := $(patsubst %,build-%,$(TARGETS) $(META_TARGETS)) +PUSH_TARGETS := $(patsubst %,push-%,$(TARGETS) $(META_TARGETS)) +TEST_TARGETS := $(patsubst %,test-%, $(TARGETS)) .PHONY: $(TARGETS) $(PUSH_TARGETS) $(BUILD_TARGETS) $(TEST_TARGETS) +push-%: DIST = $(*) $(PUSH_TARGETS): push-%: $(DOCKER) push "$(IMAGE_NAME):$(IMAGE_TAG)" @@ -56,41 +59,50 @@ push-short: build-%: DIST = $(*) build-%: DOCKERFILE = $(CURDIR)/build/container/Dockerfile.$(DOCKERFILE_SUFFIX) +ARTIFACTS_ROOT ?= $(shell realpath --relative-to=$(CURDIR) $(DIST_DIR)) + # Use a generic build target to build the relevant images -$(BUILD_TARGETS): build-%: $(ARTIFACTS_DIR) - $(DOCKER) build --pull \ +$(BUILD_TARGETS): build-%: $(ARTIFACTS_ROOT) + DOCKER_BUILDKIT=1 \ + $(DOCKER) build --pull \ + --platform=linux/amd64 \ --tag $(IMAGE) \ - --build-arg ARTIFACTS_DIR="$(ARTIFACTS_DIR)" \ + --build-arg ARTIFACTS_ROOT="$(ARTIFACTS_ROOT)" \ --build-arg BASE_DIST="$(BASE_DIST)" \ --build-arg CUDA_VERSION="$(CUDA_VERSION)" \ --build-arg GOLANG_VERSION="$(GOLANG_VERSION)" \ + --build-arg PACKAGE_DIST="$(PACKAGE_DIST)" \ --build-arg PACKAGE_VERSION="$(PACKAGE_VERSION)" \ + --build-arg PACKAGE_ARCH="$(PACKAGE_ARCH)" \ --build-arg VERSION="$(VERSION)" \ -f $(DOCKERFILE) \ $(CURDIR) -ARTIFACTS_ROOT ?= $(shell realpath --relative-to=$(CURDIR) $(DIST_DIR)) - +build-ubuntu%: BASE_DIST = $(*) build-ubuntu%: DOCKERFILE_SUFFIX := ubuntu -build-ubuntu%: ARTIFACTS_DIR = $(ARTIFACTS_ROOT)/$(*)/amd64 +build-ubuntu%: PACKAGE_ARCH := amd64 +build-ubuntu%: PACKAGE_DIST = $(BASE_DIST) build-ubuntu%: PACKAGE_VERSION := $(LIB_VERSION)$(if $(LIB_TAG),~$(LIB_TAG)) -build-ubuntu18.04: BASE_DIST := ubuntu18.04 -build-ubuntu20.04: BASE_DIST := ubuntu20.04 - -build-ubi8: DOCKERFILE_SUFFIX := centos # TODO: Update this to use the centos8 packages -build-ubi8: ARTIFACTS_DIR = $(ARTIFACTS_ROOT)/centos7/x86_64 -build-ubi8: PACKAGE_VERSION := $(LIB_VERSION)-$(if $(LIB_TAG),0.1.$(LIB_TAG),1) build-ubi8: BASE_DIST := ubi8 +build-ubi8: DOCKERFILE_SUFFIX := centos +build-ubi8: PACKAGE_ARCH := x86_64 +build-ubi8: PACKAGE_DIST = centos7 +build-ubi8: PACKAGE_VERSION := $(LIB_VERSION)-$(if $(LIB_TAG),0.1.$(LIB_TAG),1) +build-centos%: BASE_DIST = $(*) build-centos%: DOCKERFILE_SUFFIX := centos -build-centos%: ARTIFACTS_DIR = $(ARTIFACTS_ROOT)/$(*)/x86_64 +build-centos%: PACKAGE_ARCH := x86_64 +build-centos%: PACKAGE_DIST = $(BASE_DIST) build-centos%: PACKAGE_VERSION := $(LIB_VERSION)-$(if $(LIB_TAG),0.1.$(LIB_TAG),1) -build-centos7: BASE_DIST := centos7 -build-centos8: BASE_DIST := centos8 +build-packaging: BASE_DIST := ubuntu20.04 +build-packaging: DOCKERFILE_SUFFIX := packaging +build-packaging: PACKAGE_ARCH := amd64 +build-packaging: PACKAGE_DIST = all +build-packaging: PACKAGE_VERSION := $(LIB_VERSION)$(if $(LIB_TAG),-$(LIB_TAG)) # Test targets test-%: DIST = $(*) @@ -102,3 +114,23 @@ $(TEST_TARGETS): test-%: $(IMAGE) \ --no-cleanup-on-error +.PHONY: test-packaging +test-packaging: DIST = packaging +test-packaging: + @echo "Testing package image contents" + @$(DOCKER) run --rm $(IMAGE) test -d "/artifacts/packages/amazonlinux1/x86_64" || echo "Missing amazonlinux1/x86_64" + @$(DOCKER) run --rm $(IMAGE) test -d "/artifacts/packages/amazonlinux2/aarch64" || echo "Missing amazonlinux2/aarch64" + @$(DOCKER) run --rm $(IMAGE) test -d "/artifacts/packages/amazonlinux2/x86_64" || echo "Missing amazonlinux2/x86_64" + @$(DOCKER) run --rm $(IMAGE) test -d "/artifacts/packages/centos7/ppc64le" || echo "Missing centos7/ppc64le" + @$(DOCKER) run --rm $(IMAGE) test -d "/artifacts/packages/centos7/x86_64" || echo "Missing centos7/x86_64" + @$(DOCKER) run --rm $(IMAGE) test -d "/artifacts/packages/centos8/aarch64" || echo "Missing centos8/aarch64" + @$(DOCKER) run --rm $(IMAGE) test -d "/artifacts/packages/centos8/ppc64le" || echo "Missing centos8/ppc64le" + @$(DOCKER) run --rm $(IMAGE) test -d "/artifacts/packages/centos8/x86_64" || echo "Missing centos8/x86_64" + @$(DOCKER) run --rm $(IMAGE) test -d "/artifacts/packages/debian10/amd64" || echo "Missing debian10/amd64" + @$(DOCKER) run --rm $(IMAGE) test -d "/artifacts/packages/debian9/amd64" || echo "Missing debian9/amd64" + @$(DOCKER) run --rm $(IMAGE) test -d "/artifacts/packages/opensuse-leap15.1/x86_64" || echo "Missing opensuse-leap15.1/x86_64" + @$(DOCKER) run --rm $(IMAGE) test -d "/artifacts/packages/ubuntu16.04/amd64" || echo "Missing ubuntu16.04/amd64" + @$(DOCKER) run --rm $(IMAGE) test -d "/artifacts/packages/ubuntu16.04/ppc64le" || echo "Missing ubuntu16.04/ppc64le" + @$(DOCKER) run --rm $(IMAGE) test -d "/artifacts/packages/ubuntu18.04/amd64" || echo "Missing ubuntu18.04/amd64" + @$(DOCKER) run --rm $(IMAGE) test -d "/artifacts/packages/ubuntu18.04/arm64" || echo "Missing ubuntu18.04/arm64" + @$(DOCKER) run --rm $(IMAGE) test -d "/artifacts/packages/ubuntu18.04/ppc64le" || echo "Missing ubuntu18.04/ppc64le" diff --git a/scripts/pull-packages.sh b/scripts/pull-packages.sh new file mode 100755 index 00000000..f62e0bb4 --- /dev/null +++ b/scripts/pull-packages.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +# 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. + +function assert_usage() { + echo "Incorrect arguments: $*" + echo "$(basename ${BASH_SOURCE[0]}) IMAGE DIST_DIR" + exit 1 +} + +set -e -x + +SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/../scripts && pwd )" +PROJECT_ROOT="$( cd ${SCRIPTS_DIR}/.. && pwd )" + +if [[ $# -ne 2 ]]; then + assert_usage $* +fi + +IMAGE=$1 +DIST_DIR=$2 + +if [[ -z ${IMAGE} ]]; then + echo "ERROR: IMAGE must be non-empty" + exit 1 +fi + +if [[ -z ${DIST_DIR} ]]; then + echo "ERROR: DIST_DIR must be non-empty" + exit 1 +fi + +if [[ -e ${DIST_DIR} ]]; then + echo "ERROR: The specified DIST_DIR ${DIST_DIR} exists." + exit 1 +fi + +echo "Copying package files from ${IMAGE} to ${DIST_DIR}" +mkdir -p ${DIST_DIR} +docker run --rm \ + -v $(pwd):$(pwd) \ + -w $(pwd) \ + -u $(id -u):$(id -g) \ + --entrypoint="bash" \ + ${IMAGE} \ + -c "cp -R /artifacts/packages/* ${DIST_DIR}"