-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathMakefile
More file actions
158 lines (138 loc) · 6.71 KB
/
Copy pathMakefile
File metadata and controls
158 lines (138 loc) · 6.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# Makefile for building and packaging ROCm K8s Device Plugin Docker images
# Import development related environment variables from dev.env
ifneq ("$(wildcard dev.env)","")
include dev.env
endif
# Use bash with pipefail to catch errors in pipe chains
SHELL := /bin/bash
.SHELLFLAGS := -o pipefail -c
# Image repository and version
IMAGE_REPO ?= docker.io/rocm/k8s-device-plugin
IMAGE_VERSION ?= latest
# Image tags based on the repository's tagging scheme
# Alpine device plugin: latest / <version>
# Alpine labeller: labeller-latest / labeller-<version>
# UBI device plugin: rhubi-latest / rhubi-<version>
# UBI labeller: labeller-rhubi-latest / labeller-rhubi-<version>
DEVICE_PLUGIN_TAG ?= $(IMAGE_VERSION)
LABELLER_TAG ?= labeller-$(IMAGE_VERSION)
UBI_DEVICE_PLUGIN_TAG ?= rhubi-$(IMAGE_VERSION)
UBI_LABELLER_TAG ?= labeller-rhubi-$(IMAGE_VERSION)
GOLANG_BASE_IMG ?= golang:1.26.4-alpine3.23
ALPINE_BASE_IMG ?= alpine:3.23.4
# Output directory for tar.gz files
OUTPUT_DIR ?= ./dist
TAR_DIR ?= $(OUTPUT_DIR)/tarballs
.PHONY: all build-all save-all clean help
.PHONY: build-device-plugin build-labeller build-ubi-device-plugin build-ubi-labeller
.PHONY: save-device-plugin save-labeller save-ubi-device-plugin save-ubi-labeller
# Default target
all: build-all save-all
# Build all images
build-all: build-device-plugin build-labeller build-ubi-device-plugin build-ubi-labeller
@echo "All images built successfully"
# Save all images to tar.gz
save-all: save-device-plugin save-labeller save-ubi-device-plugin save-ubi-labeller
@echo "All images saved to $(TAR_DIR)/"
# Build Alpine-based device plugin image
build-device-plugin:
@echo "Building Alpine-based device plugin image..."
docker build -t $(IMAGE_REPO):$(DEVICE_PLUGIN_TAG) \
--build-arg GOLANG_BASE_IMG=$(GOLANG_BASE_IMG) \
--build-arg ALPINE_BASE_IMG=$(ALPINE_BASE_IMG) \
-f Dockerfile .
@echo "Built: $(IMAGE_REPO):$(DEVICE_PLUGIN_TAG)"
# Build Alpine-based node labeller image
build-labeller:
@echo "Building Alpine-based node labeller image..."
docker build -t $(IMAGE_REPO):$(LABELLER_TAG) \
--build-arg GOLANG_BASE_IMG=$(GOLANG_BASE_IMG) \
--build-arg ALPINE_BASE_IMG=$(ALPINE_BASE_IMG) \
-f labeller.Dockerfile .
@echo "Built: $(IMAGE_REPO):$(LABELLER_TAG)"
# Build UBI-based device plugin image
build-ubi-device-plugin:
@echo "Building UBI-based device plugin image..."
docker build -t $(IMAGE_REPO):$(UBI_DEVICE_PLUGIN_TAG) -f ubi-dp.Dockerfile .
@echo "Built: $(IMAGE_REPO):$(UBI_DEVICE_PLUGIN_TAG)"
# Build UBI-based node labeller image
build-ubi-labeller:
@echo "Building UBI-based node labeller image..."
docker build -t $(IMAGE_REPO):$(UBI_LABELLER_TAG) -f ubi-labeller.Dockerfile .
@echo "Built: $(IMAGE_REPO):$(UBI_LABELLER_TAG)"
# Save Alpine device plugin image to tar.gz
save-device-plugin: build-device-plugin
@echo "Saving $(IMAGE_REPO):$(DEVICE_PLUGIN_TAG) to tar.gz..."
@mkdir -p $(TAR_DIR)
docker save $(IMAGE_REPO):$(DEVICE_PLUGIN_TAG) | gzip > $(TAR_DIR)/k8s-device-plugin-$(DEVICE_PLUGIN_TAG).tar.gz
@echo "Saved to: $(TAR_DIR)/k8s-device-plugin-$(DEVICE_PLUGIN_TAG).tar.gz"
# Save Alpine node labeller image to tar.gz
save-labeller: build-labeller
@echo "Saving $(IMAGE_REPO):$(LABELLER_TAG) to tar.gz..."
@mkdir -p $(TAR_DIR)
docker save $(IMAGE_REPO):$(LABELLER_TAG) | gzip > $(TAR_DIR)/k8s-node-labeller-$(IMAGE_VERSION).tar.gz
@echo "Saved to: $(TAR_DIR)/k8s-node-labeller-$(IMAGE_VERSION).tar.gz"
# Save UBI device plugin image to tar.gz
save-ubi-device-plugin: build-ubi-device-plugin
@echo "Saving $(IMAGE_REPO):$(UBI_DEVICE_PLUGIN_TAG) to tar.gz..."
@mkdir -p $(TAR_DIR)
docker save $(IMAGE_REPO):$(UBI_DEVICE_PLUGIN_TAG) | gzip > $(TAR_DIR)/k8s-device-plugin-$(UBI_DEVICE_PLUGIN_TAG).tar.gz
@echo "Saved to: $(TAR_DIR)/k8s-device-plugin-$(UBI_DEVICE_PLUGIN_TAG).tar.gz"
# Save UBI node labeller image to tar.gz
save-ubi-labeller: build-ubi-labeller
@echo "Saving $(IMAGE_REPO):$(UBI_LABELLER_TAG) to tar.gz..."
@mkdir -p $(TAR_DIR)
docker save $(IMAGE_REPO):$(UBI_LABELLER_TAG) | gzip > $(TAR_DIR)/k8s-node-labeller-rhubi-$(IMAGE_VERSION).tar.gz
@echo "Saved to: $(TAR_DIR)/k8s-node-labeller-rhubi-$(IMAGE_VERSION).tar.gz"
# Clean up built images and tar files
clean:
@echo "Cleaning up Docker images and tar files..."
-docker rmi $(IMAGE_REPO):$(DEVICE_PLUGIN_TAG) 2>/dev/null
-docker rmi $(IMAGE_REPO):$(LABELLER_TAG) 2>/dev/null
-docker rmi $(IMAGE_REPO):$(UBI_DEVICE_PLUGIN_TAG) 2>/dev/null
-docker rmi $(IMAGE_REPO):$(UBI_LABELLER_TAG) 2>/dev/null
-rm -rf $(OUTPUT_DIR)
@echo "Cleanup complete"
# Help target
help:
@echo "ROCm K8s Device Plugin - Makefile targets"
@echo ""
@echo "Usage: make [target] [IMAGE_VERSION=<version>]"
@echo ""
@echo "Available targets:"
@echo " all - Build and save all images (default)"
@echo " build-all - Build all Docker images"
@echo " save-all - Save all Docker images to tar.gz"
@echo ""
@echo "Individual build targets:"
@echo " build-device-plugin - Build Alpine device plugin (tag: $(DEVICE_PLUGIN_TAG))"
@echo " build-labeller - Build Alpine node labeller (tag: $(LABELLER_TAG))"
@echo " build-ubi-device-plugin - Build UBI device plugin (tag: $(UBI_DEVICE_PLUGIN_TAG))"
@echo " build-ubi-labeller - Build UBI node labeller (tag: $(UBI_LABELLER_TAG))"
@echo ""
@echo "Individual save targets:"
@echo " save-device-plugin - Build and save Alpine device plugin to tar.gz"
@echo " save-labeller - Build and save Alpine node labeller to tar.gz"
@echo " save-ubi-device-plugin - Build and save UBI device plugin to tar.gz"
@echo " save-ubi-labeller - Build and save UBI node labeller to tar.gz"
@echo ""
@echo "Other targets:"
@echo " clean - Remove built images and tar.gz files"
@echo " help - Show this help message"
@echo ""
@echo "Variables:"
@echo " IMAGE_VERSION - Version suffix for tags (default: latest)"
@echo " OUTPUT_DIR - Base output directory (default: ./dist)"
@echo " TAR_DIR - Directory for tarball output (default: ./dist/tarballs)"
@echo ""
@echo "Tag mapping (using IMAGE_VERSION=$(IMAGE_VERSION)):"
@echo " Alpine device plugin: $(IMAGE_REPO):$(DEVICE_PLUGIN_TAG)"
@echo " Alpine labeller: $(IMAGE_REPO):$(LABELLER_TAG)"
@echo " UBI device plugin: $(IMAGE_REPO):$(UBI_DEVICE_PLUGIN_TAG)"
@echo " UBI labeller: $(IMAGE_REPO):$(UBI_LABELLER_TAG)"
@echo ""
@echo "Examples:"
@echo " make all # Builds all with 'latest' version"
@echo " make build-all IMAGE_VERSION=1.31.0.9 # Build all with version 1.31.0.9"
@echo " make save-device-plugin # Build and save device plugin only"
@echo " make clean # Clean up images and tar files"