2021-10-11 14:33:02 +00:00
|
|
|
# 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.
|
|
|
|
|
2022-02-01 10:54:03 +00:00
|
|
|
BUILD_MULTI_ARCH_IMAGES ?= false
|
|
|
|
DOCKER ?= docker
|
|
|
|
|
|
|
|
BUILDX =
|
|
|
|
ifeq ($(BUILD_MULTI_ARCH_IMAGES),true)
|
|
|
|
BUILDX = buildx
|
|
|
|
endif
|
|
|
|
|
2021-10-11 14:33:02 +00:00
|
|
|
MKDIR ?= mkdir
|
|
|
|
DIST_DIR ?= $(CURDIR)/dist
|
|
|
|
|
|
|
|
##### Global variables #####
|
2021-11-29 13:35:41 +00:00
|
|
|
include $(CURDIR)/versions.mk
|
2021-10-11 14:33:02 +00:00
|
|
|
|
|
|
|
ifeq ($(IMAGE_NAME),)
|
|
|
|
REGISTRY ?= nvidia
|
|
|
|
IMAGE_NAME := $(REGISTRY)/container-toolkit
|
|
|
|
endif
|
|
|
|
|
2021-11-29 13:35:41 +00:00
|
|
|
VERSION ?= $(LIB_VERSION)$(if $(LIB_TAG),-$(LIB_TAG))
|
2022-02-01 13:14:33 +00:00
|
|
|
IMAGE_VERSION := $(VERSION)
|
2021-11-29 13:35:41 +00:00
|
|
|
|
2021-10-11 14:33:02 +00:00
|
|
|
IMAGE_TAG ?= $(VERSION)-$(DIST)
|
|
|
|
IMAGE = $(IMAGE_NAME):$(IMAGE_TAG)
|
|
|
|
|
2022-02-01 13:14:33 +00:00
|
|
|
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)
|
|
|
|
|
2021-10-11 14:33:02 +00:00
|
|
|
##### Public rules #####
|
2022-06-07 09:32:20 +00:00
|
|
|
DEFAULT_PUSH_TARGET := ubuntu20.04
|
2022-06-02 08:43:32 +00:00
|
|
|
DISTRIBUTIONS := ubuntu20.04 ubuntu18.04 ubi8 centos7
|
2021-10-11 14:33:02 +00:00
|
|
|
|
2021-11-26 14:15:46 +00:00
|
|
|
META_TARGETS := packaging
|
|
|
|
|
2022-02-01 10:10:07 +00:00
|
|
|
BUILD_TARGETS := $(patsubst %,build-%,$(DISTRIBUTIONS) $(META_TARGETS))
|
|
|
|
PUSH_TARGETS := $(patsubst %,push-%,$(DISTRIBUTIONS) $(META_TARGETS))
|
|
|
|
TEST_TARGETS := $(patsubst %,test-%, $(DISTRIBUTIONS))
|
2021-10-11 14:33:02 +00:00
|
|
|
|
2022-02-01 10:10:07 +00:00
|
|
|
.PHONY: $(DISTRIBUTIONS) $(PUSH_TARGETS) $(BUILD_TARGETS) $(TEST_TARGETS)
|
2021-10-11 14:33:02 +00:00
|
|
|
|
2022-02-01 13:14:33 +00:00
|
|
|
ifneq ($(BUILD_MULTI_ARCH_IMAGES),true)
|
|
|
|
include $(CURDIR)/build/container/native-only.mk
|
2022-02-01 10:54:03 +00:00
|
|
|
else
|
2022-02-01 13:14:33 +00:00
|
|
|
include $(CURDIR)/build/container/multi-arch.mk
|
|
|
|
endif
|
2021-10-11 14:33:02 +00:00
|
|
|
|
|
|
|
# For the default push target we also push a short tag equal to the version.
|
|
|
|
# We skip this for the development release
|
2021-10-27 11:25:12 +00:00
|
|
|
DEVEL_RELEASE_IMAGE_VERSION ?= devel
|
2022-02-22 08:18:01 +00:00
|
|
|
PUSH_MULTIPLE_TAGS ?= true
|
|
|
|
ifeq ($(strip $(OUT_IMAGE_VERSION)),$(DEVEL_RELEASE_IMAGE_VERSION))
|
|
|
|
PUSH_MULTIPLE_TAGS = false
|
|
|
|
endif
|
|
|
|
ifeq ($(PUSH_MULTIPLE_TAGS),true)
|
2021-10-11 14:33:02 +00:00
|
|
|
push-$(DEFAULT_PUSH_TARGET): push-short
|
|
|
|
endif
|
2022-02-01 13:14:33 +00:00
|
|
|
|
|
|
|
push-%: DIST = $(*)
|
|
|
|
push-short: DIST = $(DEFAULT_PUSH_TARGET)
|
2021-10-11 14:33:02 +00:00
|
|
|
|
|
|
|
build-%: DIST = $(*)
|
|
|
|
build-%: DOCKERFILE = $(CURDIR)/build/container/Dockerfile.$(DOCKERFILE_SUFFIX)
|
|
|
|
|
2021-11-26 14:15:46 +00:00
|
|
|
ARTIFACTS_ROOT ?= $(shell realpath --relative-to=$(CURDIR) $(DIST_DIR))
|
|
|
|
|
2021-10-11 14:33:02 +00:00
|
|
|
# Use a generic build target to build the relevant images
|
2021-11-26 14:15:46 +00:00
|
|
|
$(BUILD_TARGETS): build-%: $(ARTIFACTS_ROOT)
|
2021-11-23 19:59:52 +00:00
|
|
|
DOCKER_BUILDKIT=1 \
|
2022-02-01 13:14:33 +00:00
|
|
|
$(DOCKER) $(BUILDX) build --pull \
|
2022-02-01 10:54:03 +00:00
|
|
|
$(DOCKER_BUILD_OPTIONS) \
|
|
|
|
$(DOCKER_BUILD_PLATFORM_OPTIONS) \
|
2021-10-11 14:33:02 +00:00
|
|
|
--tag $(IMAGE) \
|
2021-11-26 14:15:46 +00:00
|
|
|
--build-arg ARTIFACTS_ROOT="$(ARTIFACTS_ROOT)" \
|
2021-10-11 14:33:02 +00:00
|
|
|
--build-arg BASE_DIST="$(BASE_DIST)" \
|
|
|
|
--build-arg CUDA_VERSION="$(CUDA_VERSION)" \
|
|
|
|
--build-arg GOLANG_VERSION="$(GOLANG_VERSION)" \
|
2022-02-01 10:54:03 +00:00
|
|
|
--build-arg LIBNVIDIA_CONTAINER0_VERSION="$(LIBNVIDIA_CONTAINER0_DEPENDENCY)" \
|
2021-11-26 14:15:46 +00:00
|
|
|
--build-arg PACKAGE_DIST="$(PACKAGE_DIST)" \
|
2021-10-11 14:33:02 +00:00
|
|
|
--build-arg PACKAGE_VERSION="$(PACKAGE_VERSION)" \
|
|
|
|
--build-arg VERSION="$(VERSION)" \
|
2023-01-23 13:53:02 +00:00
|
|
|
--build-arg GIT_COMMIT="$(GIT_COMMIT)" \
|
|
|
|
--build-arg GIT_BRANCH="$(GIT_BRANCH)" \
|
|
|
|
--build-arg SOURCE_DATE_EPOCH="$(SOURCE_DATE_EPOCH)" \
|
2021-12-07 14:20:25 +00:00
|
|
|
--build-arg CVE_UPDATES="$(CVE_UPDATES)" \
|
2021-10-11 14:33:02 +00:00
|
|
|
-f $(DOCKERFILE) \
|
|
|
|
$(CURDIR)
|
|
|
|
|
|
|
|
|
2021-11-26 14:15:46 +00:00
|
|
|
build-ubuntu%: BASE_DIST = $(*)
|
2021-10-11 14:33:02 +00:00
|
|
|
build-ubuntu%: DOCKERFILE_SUFFIX := ubuntu
|
2022-02-02 12:50:24 +00:00
|
|
|
build-ubuntu%: PACKAGE_DIST = ubuntu18.04
|
2021-10-11 14:33:02 +00:00
|
|
|
build-ubuntu%: PACKAGE_VERSION := $(LIB_VERSION)$(if $(LIB_TAG),~$(LIB_TAG))
|
2022-02-01 10:54:03 +00:00
|
|
|
build-ubuntu%: LIBNVIDIA_CONTAINER0_DEPENDENCY=$(LIBNVIDIA_CONTAINER0_VERSION)
|
2021-10-11 14:33:02 +00:00
|
|
|
|
|
|
|
build-ubi8: BASE_DIST := ubi8
|
2021-11-26 14:15:46 +00:00
|
|
|
build-ubi8: DOCKERFILE_SUFFIX := centos
|
2022-02-01 13:14:33 +00:00
|
|
|
build-ubi8: PACKAGE_DIST = centos8
|
2021-11-26 14:15:46 +00:00
|
|
|
build-ubi8: PACKAGE_VERSION := $(LIB_VERSION)-$(if $(LIB_TAG),0.1.$(LIB_TAG),1)
|
2021-10-11 14:33:02 +00:00
|
|
|
|
2022-06-02 08:39:53 +00:00
|
|
|
build-centos7: BASE_DIST = $(*)
|
|
|
|
build-centos7: DOCKERFILE_SUFFIX := centos
|
|
|
|
build-centos7: PACKAGE_DIST = $(BASE_DIST)
|
|
|
|
build-centos7: PACKAGE_VERSION := $(LIB_VERSION)-$(if $(LIB_TAG),0.1.$(LIB_TAG),1)
|
|
|
|
|
2021-11-25 19:02:07 +00:00
|
|
|
build-packaging: BASE_DIST := ubuntu20.04
|
|
|
|
build-packaging: DOCKERFILE_SUFFIX := packaging
|
2021-11-26 14:15:46 +00:00
|
|
|
build-packaging: PACKAGE_ARCH := amd64
|
|
|
|
build-packaging: PACKAGE_DIST = all
|
|
|
|
build-packaging: PACKAGE_VERSION := $(LIB_VERSION)$(if $(LIB_TAG),-$(LIB_TAG))
|
2021-11-25 19:02:07 +00:00
|
|
|
|
2021-10-11 14:33:02 +00:00
|
|
|
# Test targets
|
|
|
|
test-%: DIST = $(*)
|
|
|
|
|
|
|
|
TEST_CASES ?= toolkit docker crio containerd
|
|
|
|
$(TEST_TARGETS): test-%:
|
|
|
|
TEST_CASES="$(TEST_CASES)" bash -x $(CURDIR)/test/container/main.sh run \
|
|
|
|
$(CURDIR)/shared-$(*) \
|
|
|
|
$(IMAGE) \
|
|
|
|
--no-cleanup-on-error
|
|
|
|
|
2021-11-25 19:43:43 +00:00
|
|
|
.PHONY: test-packaging
|
|
|
|
test-packaging: DIST = packaging
|
|
|
|
test-packaging:
|
|
|
|
@echo "Testing package image contents"
|
|
|
|
@$(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"
|