Skip to content

Commit 48d538e

Browse files
committed
[no-relnotes] Update makefile for images
Signed-off-by: Evan Lezar <[email protected]>
1 parent 9848c3e commit 48d538e

File tree

3 files changed

+29
-12
lines changed

3 files changed

+29
-12
lines changed

deployments/container/Makefile

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@ DIST_DIR ?= $(CURDIR)/dist
2727
##### Global variables #####
2828
include $(CURDIR)/versions.mk
2929

30-
ifeq ($(IMAGE_NAME),)
31-
REGISTRY ?= nvidia
32-
IMAGE_NAME := $(REGISTRY)/container-toolkit
33-
endif
34-
35-
VERSION ?= $(LIB_VERSION)$(if $(LIB_TAG),-$(LIB_TAG))
3630
IMAGE_VERSION := $(VERSION)
3731

3832
IMAGE_TAG ?= $(VERSION)-$(DIST)
@@ -49,6 +43,7 @@ DISTRIBUTIONS := ubuntu20.04 ubi8
4943

5044
META_TARGETS := packaging
5145

46+
IMAGE_TARGETS := $(patsubst %,image-%,$(DISTRIBUTIONS) $(META_TARGETS))
5247
BUILD_TARGETS := $(patsubst %,build-%,$(DISTRIBUTIONS) $(META_TARGETS))
5348
PUSH_TARGETS := $(patsubst %,push-%,$(DISTRIBUTIONS) $(META_TARGETS))
5449
TEST_TARGETS := $(patsubst %,test-%,$(DISTRIBUTIONS))
@@ -89,7 +84,7 @@ build-%: DOCKERFILE = $(CURDIR)/deployments/container/Dockerfile.$(DOCKERFILE_SU
8984
ARTIFACTS_ROOT ?= $(shell realpath --relative-to=$(CURDIR) $(DIST_DIR))
9085

9186
# Use a generic build target to build the relevant images
92-
$(BUILD_TARGETS): build-%: $(ARTIFACTS_ROOT)
87+
$(IMAGE_TARGETS): image-%: $(ARTIFACTS_ROOT)
9388
DOCKER_BUILDKIT=1 \
9489
$(DOCKER) $(BUILDX) build --pull \
9590
--provenance=false --sbom=false \
@@ -108,7 +103,6 @@ $(BUILD_TARGETS): build-%: $(ARTIFACTS_ROOT)
108103
-f $(DOCKERFILE) \
109104
$(CURDIR)
110105

111-
112106
build-ubuntu%: DOCKERFILE_SUFFIX := ubuntu
113107
build-ubuntu%: PACKAGE_DIST = ubuntu18.04
114108

@@ -122,7 +116,13 @@ build-packaging: PACKAGE_DIST = all
122116
# Test targets
123117
test-%: DIST = $(*)
124118

125-
TEST_CASES ?= toolkit docker crio containerd
119+
# Handle the default build target.
120+
.PHONY: build
121+
build: $(DEFAULT_PUSH_TARGET)
122+
$(DEFAULT_PUSH_TARGET): build-$(DEFAULT_PUSH_TARGET)
123+
$(DEFAULT_PUSH_TARGET): DIST = $(DEFAULT_PUSH_TARGET)
124+
125+
TEST_CASES ?= docker crio containerd
126126
$(TEST_TARGETS): test-%:
127127
TEST_CASES="$(TEST_CASES)" bash -x $(CURDIR)/test/container/main.sh run \
128128
$(CURDIR)/shared-$(*) \

deployments/container/multi-arch.mk

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ PUSH_ON_BUILD ?= false
1616
DOCKER_BUILD_OPTIONS = --output=type=image,push=$(PUSH_ON_BUILD)
1717
DOCKER_BUILD_PLATFORM_OPTIONS = --platform=linux/amd64,linux/arm64
1818

19-
# We only generate amd64 image for ubuntu18.04
20-
build-ubuntu18.04: DOCKER_BUILD_PLATFORM_OPTIONS = --platform=linux/amd64
19+
$(BUILD_TARGETS): build-%: image-%
2120

2221
# We only generate a single image for packaging targets
2322
build-packaging: DOCKER_BUILD_PLATFORM_OPTIONS = --platform=linux/amd64

deployments/container/native-only.mk

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,22 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
DOCKER_BUILD_PLATFORM_OPTIONS = --platform=linux/amd64
15+
PUSH_ON_BUILD ?= false
16+
ARCH ?= $(shell uname -m)
17+
DOCKER_BUILD_PLATFORM_OPTIONS = --platform=linux/$(ARCH)
18+
19+
ifeq ($(PUSH_ON_BUILD),true)
20+
DOCKER_BUILD_OPTIONS = --output=type=image,push=$(PUSH_ON_BUILD)
21+
$(BUILD_TARGETS): build-%: image-%
22+
$(DOCKER) push "$(IMAGE)"
23+
else
24+
$(BUILD_TARGETS): build-%: image-%
25+
endif
26+
27+
# For the default distribution we also retag the image.
28+
# Note: This needs to be updated for multi-arch images.
29+
ifeq ($(IMAGE_TAG),$(VERSION)-$(DIST))
30+
$(DEFAULT_PUSH_TARGET):
31+
$(DOCKER) image inspect $(IMAGE) > /dev/null || $(DOCKER) pull $(IMAGE)
32+
$(DOCKER) tag $(IMAGE) $(subst :$(IMAGE_TAG),:$(VERSION),$(IMAGE))
33+
endif

0 commit comments

Comments
 (0)