mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2025-03-09 22:00:31 +00:00
[no-relnotes] Update makefile for images
Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
parent
9848c3e985
commit
48d538eef9
@ -27,12 +27,6 @@ DIST_DIR ?= $(CURDIR)/dist
|
|||||||
##### Global variables #####
|
##### Global variables #####
|
||||||
include $(CURDIR)/versions.mk
|
include $(CURDIR)/versions.mk
|
||||||
|
|
||||||
ifeq ($(IMAGE_NAME),)
|
|
||||||
REGISTRY ?= nvidia
|
|
||||||
IMAGE_NAME := $(REGISTRY)/container-toolkit
|
|
||||||
endif
|
|
||||||
|
|
||||||
VERSION ?= $(LIB_VERSION)$(if $(LIB_TAG),-$(LIB_TAG))
|
|
||||||
IMAGE_VERSION := $(VERSION)
|
IMAGE_VERSION := $(VERSION)
|
||||||
|
|
||||||
IMAGE_TAG ?= $(VERSION)-$(DIST)
|
IMAGE_TAG ?= $(VERSION)-$(DIST)
|
||||||
@ -49,6 +43,7 @@ DISTRIBUTIONS := ubuntu20.04 ubi8
|
|||||||
|
|
||||||
META_TARGETS := packaging
|
META_TARGETS := packaging
|
||||||
|
|
||||||
|
IMAGE_TARGETS := $(patsubst %,image-%,$(DISTRIBUTIONS) $(META_TARGETS))
|
||||||
BUILD_TARGETS := $(patsubst %,build-%,$(DISTRIBUTIONS) $(META_TARGETS))
|
BUILD_TARGETS := $(patsubst %,build-%,$(DISTRIBUTIONS) $(META_TARGETS))
|
||||||
PUSH_TARGETS := $(patsubst %,push-%,$(DISTRIBUTIONS) $(META_TARGETS))
|
PUSH_TARGETS := $(patsubst %,push-%,$(DISTRIBUTIONS) $(META_TARGETS))
|
||||||
TEST_TARGETS := $(patsubst %,test-%,$(DISTRIBUTIONS))
|
TEST_TARGETS := $(patsubst %,test-%,$(DISTRIBUTIONS))
|
||||||
@ -89,7 +84,7 @@ build-%: DOCKERFILE = $(CURDIR)/deployments/container/Dockerfile.$(DOCKERFILE_SU
|
|||||||
ARTIFACTS_ROOT ?= $(shell realpath --relative-to=$(CURDIR) $(DIST_DIR))
|
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)
|
$(IMAGE_TARGETS): image-%: $(ARTIFACTS_ROOT)
|
||||||
DOCKER_BUILDKIT=1 \
|
DOCKER_BUILDKIT=1 \
|
||||||
$(DOCKER) $(BUILDX) build --pull \
|
$(DOCKER) $(BUILDX) build --pull \
|
||||||
--provenance=false --sbom=false \
|
--provenance=false --sbom=false \
|
||||||
@ -108,7 +103,6 @@ $(BUILD_TARGETS): build-%: $(ARTIFACTS_ROOT)
|
|||||||
-f $(DOCKERFILE) \
|
-f $(DOCKERFILE) \
|
||||||
$(CURDIR)
|
$(CURDIR)
|
||||||
|
|
||||||
|
|
||||||
build-ubuntu%: DOCKERFILE_SUFFIX := ubuntu
|
build-ubuntu%: DOCKERFILE_SUFFIX := ubuntu
|
||||||
build-ubuntu%: PACKAGE_DIST = ubuntu18.04
|
build-ubuntu%: PACKAGE_DIST = ubuntu18.04
|
||||||
|
|
||||||
@ -122,7 +116,13 @@ build-packaging: PACKAGE_DIST = all
|
|||||||
# Test targets
|
# Test targets
|
||||||
test-%: DIST = $(*)
|
test-%: DIST = $(*)
|
||||||
|
|
||||||
TEST_CASES ?= toolkit docker crio containerd
|
# Handle the default build target.
|
||||||
|
.PHONY: build
|
||||||
|
build: $(DEFAULT_PUSH_TARGET)
|
||||||
|
$(DEFAULT_PUSH_TARGET): build-$(DEFAULT_PUSH_TARGET)
|
||||||
|
$(DEFAULT_PUSH_TARGET): DIST = $(DEFAULT_PUSH_TARGET)
|
||||||
|
|
||||||
|
TEST_CASES ?= docker crio containerd
|
||||||
$(TEST_TARGETS): test-%:
|
$(TEST_TARGETS): test-%:
|
||||||
TEST_CASES="$(TEST_CASES)" bash -x $(CURDIR)/test/container/main.sh run \
|
TEST_CASES="$(TEST_CASES)" bash -x $(CURDIR)/test/container/main.sh run \
|
||||||
$(CURDIR)/shared-$(*) \
|
$(CURDIR)/shared-$(*) \
|
||||||
|
@ -16,8 +16,7 @@ PUSH_ON_BUILD ?= false
|
|||||||
DOCKER_BUILD_OPTIONS = --output=type=image,push=$(PUSH_ON_BUILD)
|
DOCKER_BUILD_OPTIONS = --output=type=image,push=$(PUSH_ON_BUILD)
|
||||||
DOCKER_BUILD_PLATFORM_OPTIONS = --platform=linux/amd64,linux/arm64
|
DOCKER_BUILD_PLATFORM_OPTIONS = --platform=linux/amd64,linux/arm64
|
||||||
|
|
||||||
# We only generate amd64 image for ubuntu18.04
|
$(BUILD_TARGETS): build-%: image-%
|
||||||
build-ubuntu18.04: DOCKER_BUILD_PLATFORM_OPTIONS = --platform=linux/amd64
|
|
||||||
|
|
||||||
# We only generate a single image for packaging targets
|
# We only generate a single image for packaging targets
|
||||||
build-packaging: DOCKER_BUILD_PLATFORM_OPTIONS = --platform=linux/amd64
|
build-packaging: DOCKER_BUILD_PLATFORM_OPTIONS = --platform=linux/amd64
|
||||||
|
@ -12,4 +12,22 @@
|
|||||||
# 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_BUILD_PLATFORM_OPTIONS = --platform=linux/amd64
|
PUSH_ON_BUILD ?= false
|
||||||
|
ARCH ?= $(shell uname -m)
|
||||||
|
DOCKER_BUILD_PLATFORM_OPTIONS = --platform=linux/$(ARCH)
|
||||||
|
|
||||||
|
ifeq ($(PUSH_ON_BUILD),true)
|
||||||
|
DOCKER_BUILD_OPTIONS = --output=type=image,push=$(PUSH_ON_BUILD)
|
||||||
|
$(BUILD_TARGETS): build-%: image-%
|
||||||
|
$(DOCKER) push "$(IMAGE)"
|
||||||
|
else
|
||||||
|
$(BUILD_TARGETS): build-%: image-%
|
||||||
|
endif
|
||||||
|
|
||||||
|
# For the default distribution we also retag the image.
|
||||||
|
# Note: This needs to be updated for multi-arch images.
|
||||||
|
ifeq ($(IMAGE_TAG),$(VERSION)-$(DIST))
|
||||||
|
$(DEFAULT_PUSH_TARGET):
|
||||||
|
$(DOCKER) image inspect $(IMAGE) > /dev/null || $(DOCKER) pull $(IMAGE)
|
||||||
|
$(DOCKER) tag $(IMAGE) $(subst :$(IMAGE_TAG),:$(VERSION),$(IMAGE))
|
||||||
|
endif
|
||||||
|
Loading…
Reference in New Issue
Block a user