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.
|
|
|
|
|
|
|
|
DOCKER ?= docker
|
|
|
|
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))
|
|
|
|
|
2021-10-11 14:33:02 +00:00
|
|
|
IMAGE_TAG ?= $(VERSION)-$(DIST)
|
|
|
|
IMAGE = $(IMAGE_NAME):$(IMAGE_TAG)
|
|
|
|
|
|
|
|
##### Public rules #####
|
|
|
|
DEFAULT_PUSH_TARGET := ubuntu18.04
|
2021-11-25 19:02:07 +00:00
|
|
|
TARGETS := ubuntu20.04 ubuntu18.04 ubi8 centos7 centos8 packaging
|
2021-10-11 14:33:02 +00:00
|
|
|
|
|
|
|
BUILD_TARGETS := $(patsubst %, build-%, $(TARGETS))
|
2021-10-13 12:04:41 +00:00
|
|
|
PUSH_TARGETS := $(patsubst %, push-%, $(TARGETS))
|
2021-11-25 19:02:07 +00:00
|
|
|
TEST_TARGETS := $(patsubst %, test-%, $(filter-out packaging,$(TARGETS)))
|
2021-10-11 14:33:02 +00:00
|
|
|
|
|
|
|
.PHONY: $(TARGETS) $(PUSH_TARGETS) $(BUILD_TARGETS) $(TEST_TARGETS)
|
|
|
|
|
2021-11-25 19:02:07 +00:00
|
|
|
push-%: DIST = $(*)
|
2021-10-11 14:33:02 +00:00
|
|
|
$(PUSH_TARGETS): push-%:
|
|
|
|
$(DOCKER) push "$(IMAGE_NAME):$(IMAGE_TAG)"
|
|
|
|
|
|
|
|
# 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
|
|
|
|
ifneq ($(strip $(VERSION)),$(DEVEL_RELEASE_IMAGE_VERSION))
|
2021-10-11 14:33:02 +00:00
|
|
|
push-$(DEFAULT_PUSH_TARGET): push-short
|
|
|
|
endif
|
|
|
|
push-short:
|
|
|
|
$(DOCKER) tag "$(IMAGE_NAME):$(VERSION)-$(DEFAULT_PUSH_TARGET)" "$(IMAGE_NAME):$(VERSION)"
|
|
|
|
$(DOCKER) push "$(IMAGE_NAME):$(VERSION)"
|
|
|
|
|
|
|
|
|
|
|
|
build-%: DIST = $(*)
|
|
|
|
build-%: DOCKERFILE = $(CURDIR)/build/container/Dockerfile.$(DOCKERFILE_SUFFIX)
|
|
|
|
|
|
|
|
# Use a generic build target to build the relevant images
|
|
|
|
$(BUILD_TARGETS): build-%: $(ARTIFACTS_DIR)
|
2021-11-23 19:59:52 +00:00
|
|
|
DOCKER_BUILDKIT=1 \
|
|
|
|
$(DOCKER) build --platform=linux/amd64 --pull \
|
2021-10-11 14:33:02 +00:00
|
|
|
--tag $(IMAGE) \
|
|
|
|
--build-arg ARTIFACTS_DIR="$(ARTIFACTS_DIR)" \
|
|
|
|
--build-arg BASE_DIST="$(BASE_DIST)" \
|
|
|
|
--build-arg CUDA_VERSION="$(CUDA_VERSION)" \
|
|
|
|
--build-arg GOLANG_VERSION="$(GOLANG_VERSION)" \
|
|
|
|
--build-arg PACKAGE_VERSION="$(PACKAGE_VERSION)" \
|
2021-11-23 19:59:52 +00:00
|
|
|
--build-arg PACKAGE_ARCH="$(PACKAGE_ARCH)" \
|
2021-10-11 14:33:02 +00:00
|
|
|
--build-arg VERSION="$(VERSION)" \
|
|
|
|
-f $(DOCKERFILE) \
|
|
|
|
$(CURDIR)
|
|
|
|
|
|
|
|
|
2021-10-13 12:04:41 +00:00
|
|
|
ARTIFACTS_ROOT ?= $(shell realpath --relative-to=$(CURDIR) $(DIST_DIR))
|
2021-11-23 19:59:52 +00:00
|
|
|
ARTIFACTS_DIR = $(ARTIFACTS_ROOT)/$(*)
|
|
|
|
|
|
|
|
PACKAGE_ARCH = amd64
|
2021-10-13 12:04:41 +00:00
|
|
|
|
2021-10-11 14:33:02 +00:00
|
|
|
build-ubuntu%: DOCKERFILE_SUFFIX := ubuntu
|
|
|
|
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
|
2021-11-23 19:59:52 +00:00
|
|
|
build-ubi8: ARTIFACTS_DIR = $(ARTIFACTS_ROOT)/centos7
|
2021-10-11 14:33:02 +00:00
|
|
|
build-ubi8: PACKAGE_VERSION := $(LIB_VERSION)-$(if $(LIB_TAG),0.1.$(LIB_TAG),1)
|
|
|
|
build-ubi8: BASE_DIST := ubi8
|
2021-11-23 19:59:52 +00:00
|
|
|
build-ubi8: PACKAGE_ARCH := x86_64
|
2021-10-11 14:33:02 +00:00
|
|
|
|
|
|
|
build-centos%: DOCKERFILE_SUFFIX := centos
|
|
|
|
build-centos%: PACKAGE_VERSION := $(LIB_VERSION)-$(if $(LIB_TAG),0.1.$(LIB_TAG),1)
|
2021-11-23 19:59:52 +00:00
|
|
|
build-centos%: PACKAGE_ARCH := x86_64
|
2021-10-11 14:33:02 +00:00
|
|
|
|
|
|
|
build-centos7: BASE_DIST := centos7
|
|
|
|
build-centos8: BASE_DIST := centos8
|
|
|
|
|
2021-11-25 19:02:07 +00:00
|
|
|
build-packaging: BASE_DIST := ubuntu20.04
|
|
|
|
build-packaging: DOCKERFILE_SUFFIX := packaging
|
|
|
|
build-packaging: ARTIFACTS_DIR = $(ARTIFACTS_ROOT)
|
|
|
|
|
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
|
|
|
|
|