@@ -117,43 +117,25 @@ goimports: localbin ## Download goimports locally if necessary. If wrong version
117117 echo $(FORMATTER_VERSION ) > hack/goimports_version )
118118
119119# #@ Build
120-
121- .PHONY : build
122- build : manifests generate fmt vet # # Build manager binary.
123- go build -o bin/manager cmd/main.go
120+ build : generate # # Builds binaries for all components specified in COMPONENTS and all platforms specified in PLATFORMS.
121+ @PLATFORMS=$(PLATFORMS ) COMPONENTS=control-plane-operator ./hack/common/build-binary.sh
124122
125123.PHONY : run
126124run : manifests generate fmt vet # # Run a controller from your host.
127125 go run ./cmd/main.go start
128126
129- # If you wish to build the manager image targeting other platforms you can use the --platform flag.
130- # (i.e. docker build --platform linux/arm64). However, you must enable docker buildKit for it.
131- # More info: https://docs.docker.com/develop/develop-images/build_enhancements/
132- .PHONY : docker -build
133- docker -build : # # Build docker image with the manager .
134- CGO_ENABLED=0 GOOS= $( GOOS ) GOARCH= $( GOARCH ) go build -a -o bin/manager-linux. $( GOARCH ) cmd/main.go
135- $( CONTAINER_TOOL ) build --platform $( CONTAINER_PLATFORM ) -t ${IMG} .
127+ PLATFORMS ?= linux/arm64,linux/amd64
128+ EFFECTIVE_VERSION ?= $( shell cat ./VERSION)
129+
130+ .PHONY : image -build
131+ image -build : # # Builds the docker images for all components specified in COMPONENTS and all platforms specified in PLATFORMS. Requires 'make build' to have run before .
132+ @PLATFORMS= $( PLATFORMS ) COMPONENTS=control-plane-operator EFFECTIVE_VERSION= $( EFFECTIVE_VERSION ) ./hack/common/build-image.sh
133+
136134
137135.PHONY : docker-push
138136docker-push : # # Push docker image with the manager.
139137 $(CONTAINER_TOOL ) push ${IMG}
140138
141- # PLATFORMS defines the target platforms for the manager image be built to provide support to multiple
142- # architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to:
143- # - be able to use docker buildx. More info: https://docs.docker.com/build/buildx/
144- # - have enabled BuildKit. More info: https://docs.docker.com/develop/develop-images/build_enhancements/
145- # - 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)
146- # To adequately provide solutions that are compatible with multiple platforms, you should consider using this option.
147- PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
148- .PHONY : docker-buildx
149- docker-buildx : # # Build and push docker image for the manager for cross-platform support
150- # copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
151- sed -e ' 1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
152- - $(CONTAINER_TOOL ) buildx create --name project-v3-builder
153- $(CONTAINER_TOOL ) buildx use project-v3-builder
154- - $(CONTAINER_TOOL ) buildx build --push --platform=$(PLATFORMS ) --tag ${IMG} -f Dockerfile.cross .
155- - $(CONTAINER_TOOL ) buildx rm project-v3-builder
156- rm Dockerfile.cross
157139
158140# #@ Deployment
159141
0 commit comments