1
1
# Image URL to use all building/pushing image targets
2
2
IMG ?= asm582/instaslicev2-controller:latest
3
3
IMG_DMST ?= asm582/instaslicev2-daemonset:latest
4
+
4
5
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
5
6
ENVTEST_K8S_VERSION = 1.29.0
6
7
17
18
# tools. (i.e. podman)
18
19
CONTAINER_TOOL ?= docker
19
20
21
+ ifeq ($(CONTAINER_TOOL ) ,podman)
22
+ MULTI_ARCH_OPTION =--manifest
23
+ else
24
+ MULTI_ARCH_OPTION =--push --provenance=false --tag
25
+ endif
26
+
27
+
20
28
# Setting SHELL to bash allows bash commands to be executed by recipes.
21
29
# Options are set to exit when a recipe line exits non-zero or a piped command fails.
22
30
SHELL = /usr/bin/env bash -o pipefail
@@ -93,11 +101,11 @@ build: manifests generate fmt vet ## Build manager binary.
93
101
go build -o bin/daemonset cmd/daemonset/main.go
94
102
.PHONY : run-controller
95
103
run-controller : manifests generate fmt vet # # Run a controller from your host.
96
- sudo -E go run ./cmd/controller/main.go
104
+ sudo -E go run ./cmd/controller/main.go
97
105
98
106
.PHONY : run-daemonset
99
107
run-daemonset : manifests generate fmt vet # # Run a controller from your host.
100
- sudo -E go run ./cmd/daemonset/main.go
108
+ sudo -E go run ./cmd/daemonset/main.go
101
109
102
110
# If you wish to build the manager image targeting other platforms you can use the --platform flag.
103
111
# (i.e. docker build --platform linux/arm64). However, you must enable docker buildKit for it.
@@ -113,21 +121,23 @@ docker-push: ## Push docker image with the manager.
113
121
$(CONTAINER_TOOL ) push ${IMG_DMST}
114
122
115
123
# PLATFORMS defines the target platforms for the manager image be built to provide support to multiple
116
- # architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to:
117
- # - be able to use docker buildx. More info: https://docs.docker.com/build/buildx/
118
- # - have enabled BuildKit. More info: https://docs.docker.com/develop/develop-images/build_enhancements/
119
- # - be able to push the image to your registry (i.e. if you do not set a valid value via IMG=<myregistry/image:<tag>> then the export will fail)
120
- # To adequately provide solutions that are compatible with multiple platforms, you should consider using this option.
121
- PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
124
+ # architectures. Make sure that base image in the Dockerfile/Containerfile is itself multi-platform, and includes
125
+ # the requested plaforms. Unlike "docker buildx", for multi-platform images podman requires creating a manifest.
126
+ PLATFORMS ?= linux/arm64,linux/amd64
122
127
.PHONY : docker-buildx
123
- docker-buildx : # # Build and push docker image for the manager for cross-platform support
124
- # copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
125
- sed -e ' 1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
126
- - $(CONTAINER_TOOL ) buildx create --name project-v3-builder
127
- $(CONTAINER_TOOL ) buildx use project-v3-builder
128
- - $(CONTAINER_TOOL ) buildx build --push --platform=$(PLATFORMS ) --tag ${IMG} -f Dockerfile.cross .
129
- - $(CONTAINER_TOOL ) buildx rm project-v3-builder
130
- rm Dockerfile.cross
128
+ docker-buildx : # # Build and push docker images with multi-platform support
129
+ if [ " $( CONTAINER_TOOL) " == " podman" ]; then \
130
+ $(CONTAINER_TOOL ) manifest rm ${IMG} || true ; \
131
+ $(CONTAINER_TOOL ) manifest create ${IMG} ; \
132
+ $(CONTAINER_TOOL ) manifest rm ${IMG_DMST} || true ; \
133
+ $(CONTAINER_TOOL ) manifest create ${IMG_DMST} ; \
134
+ fi
135
+ DOCKER_BUILDKIT=1 $(CONTAINER_TOOL ) buildx build --platform=$(PLATFORMS ) $(MULTI_ARCH_OPTION ) ${IMG} -f Dockerfile.controller .
136
+ DOCKER_BUILDKIT=1 $(CONTAINER_TOOL ) buildx build --platform=$(PLATFORMS ) $(MULTI_ARCH_OPTION ) ${IMG_DMST} -f Dockerfile.daemonset .
137
+ if [ " $( CONTAINER_TOOL) " == " podman" ]; then \
138
+ $(CONTAINER_TOOL ) manifest push ${IMG} ; \
139
+ $(CONTAINER_TOOL ) manifest push ${IMG_DMST} ; \
140
+ fi
131
141
132
142
.PHONY : build-installer
133
143
build-installer : manifests generate kustomize # # Generate a consolidated YAML with CRDs and deployment.
0 commit comments