|
1 | 1 | REGISTRY ?= workload-images |
2 | 2 | TAG ?= latest |
3 | 3 |
|
4 | | -BUILDER ?= docker |
5 | | -RUNNER ?= docker |
| 4 | +BUILDER ?= docker buildx |
6 | 5 |
|
7 | 6 | WORKLOADS=$(shell find workloads -mindepth 2 -maxdepth 2 -type f -name 'Dockerfile' | sort -u | cut -f 2 -d'/') |
8 | 7 | TOOLS=$(shell find tools -mindepth 2 -maxdepth 2 -type f -name 'Dockerfile' | sort -u | cut -f 2 -d'/') |
9 | 8 |
|
10 | | -build: |
| 9 | +MACHINE = qubesome |
| 10 | + |
| 11 | +# ACTION can only be --load when TARGET_PLATFORM is the current platform: |
| 12 | +# TARGET_PLATFORMS=linux/amd64 ACTION=--load make push-workload-xorg |
| 13 | +ACTION ?= --load |
| 14 | +TARGET_PLATFORMS ?= $(shell docker info --format '{{.ClientInfo.Os}}/{{.ClientInfo.Arch}}') |
| 15 | +SUPPORTED_PLATFORMS = linux/amd64,linux/arm64 |
| 16 | + |
| 17 | +build: build-workload-base |
11 | 18 | $(MAKE) $(addprefix build-workload-, $(WORKLOADS)) |
12 | 19 | $(MAKE) $(addprefix build-tool-, $(TOOLS)) |
13 | 20 |
|
14 | | -build-workload-%: |
| 21 | +buildx-machine: |
| 22 | + $(BUILDER) use $(MACHINE) >/dev/null 2>&1 || \ |
| 23 | + $(BUILDER) create --name=$(MACHINE) --platform=$(SUPPORTED_PLATFORMS) |
| 24 | + |
| 25 | +build-workload-%: buildx-machine |
15 | 26 | cd workloads/$(subst :,/,$*); \ |
16 | | - $(BUILDER) build --build-arg=REGISTRY=$(REGISTRY) --build-arg=TAG=$(TAG) \ |
17 | | - --load -t $(REGISTRY)/$(subst :,/,$*):$(TAG) -f Dockerfile . |
| 27 | + $(BUILDER) build --builder $(MACHINE) --platform="$(TARGET_PLATFORMS)" \ |
| 28 | + --build-arg=REGISTRY=$(REGISTRY) --build-arg=TAG=$(TAG) \ |
| 29 | + $(ACTION) -t $(REGISTRY)/$(subst :,/,$*):$(TAG) -f Dockerfile . |
18 | 30 |
|
19 | | -build-tool-%: |
| 31 | +build-tool-%: buildx-machine |
20 | 32 | cd tools/$(subst :,/,$*); \ |
21 | | - $(BUILDER) build --build-arg=REGISTRY=$(REGISTRY) --build-arg=TAG=$(TAG) \ |
22 | | - -t $(REGISTRY)/$(subst :,/,$*):$(TAG) -f Dockerfile . |
| 33 | + $(BUILDER) build --builder $(MACHINE) --platform="$(TARGET_PLATFORMS)" \ |
| 34 | + --build-arg=REGISTRY=$(REGISTRY) --build-arg=TAG=$(TAG) \ |
| 35 | + $(ACTION) -t $(REGISTRY)/$(subst :,/,$*):$(TAG) -f Dockerfile . |
23 | 36 |
|
24 | 37 | push: |
25 | 38 | $(MAKE) $(addprefix push-workload-, $(WORKLOADS)) |
26 | 39 | $(MAKE) $(addprefix push-tool-, $(TOOLS)) |
27 | 40 |
|
28 | | -push-workload-%: build-workload-% |
29 | | - cd workloads/$(subst :,/,$*); \ |
30 | | - $(BUILDER) push $(REGISTRY)/$(subst :,/,$*):$(TAG) |
| 41 | +push-workload-%: |
| 42 | + ACTION=--push \ |
| 43 | + TARGET_PLATFORMS=$(SUPPORTED_PLATFORMS) \ |
| 44 | + $(MAKE) build-workload-$(subst :,/,$*) |
| 45 | + |
31 | 46 | ifneq ($(TAG),latest) |
32 | 47 | cosign sign --yes "$(REGISTRY)/$(subst :,/,$*):$(TAG)" |
33 | 48 | endif |
|
0 commit comments