44 lines
2.3 KiB
Makefile
44 lines
2.3 KiB
Makefile
##@ Build
|
|
|
|
.PHONY: build
|
|
build: manifests generate fmt vet ## Build manager binary.
|
|
go build -o bin/manager cmd/main.go
|
|
|
|
.PHONY: run
|
|
run: manifests generate fmt vet ## Run a controller from your host (webhook off; no host certs needed).
|
|
ENABLE_WEBHOOKS=false go run ./cmd/main.go
|
|
|
|
# If you wish to build the manager image targeting other platforms you can use the --platform flag.
|
|
# (i.e. docker build --platform linux/arm64). However, you must enable docker buildKit for it.
|
|
# More info: https://docs.docker.com/develop/develop-images/build_enhancements/
|
|
.PHONY: docker-build
|
|
docker-build: ## Build docker image with the manager.
|
|
$(CONTAINER_TOOL) build -t ${IMG} .
|
|
|
|
.PHONY: docker-push
|
|
docker-push: ## Push docker image with the manager.
|
|
$(CONTAINER_TOOL) push ${IMG}
|
|
|
|
# PLATFORMS defines the target platforms for the manager image be built to provide support to multiple
|
|
# architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to:
|
|
# - be able to use docker buildx. More info: https://docs.docker.com/build/buildx/
|
|
# - have enabled BuildKit. More info: https://docs.docker.com/develop/develop-images/build_enhancements/
|
|
# - 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)
|
|
# To adequately provide solutions that are compatible with multiple platforms, you should consider using this option.
|
|
PLATFORMS ?= linux/amd64
|
|
.PHONY: docker-buildx
|
|
docker-buildx: ## Build and push docker image for the manager for cross-platform support
|
|
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
|
|
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
|
|
- $(CONTAINER_TOOL) buildx create --name operator-builder
|
|
$(CONTAINER_TOOL) buildx use operator-builder
|
|
- $(CONTAINER_TOOL) buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross .
|
|
- $(CONTAINER_TOOL) buildx rm operator-builder
|
|
rm Dockerfile.cross
|
|
|
|
.PHONY: build-installer
|
|
build-installer: manifests generate kustomize ## Generate a consolidated YAML with CRDs and deployment.
|
|
mkdir -p dist
|
|
cd config/manager && "$(KUSTOMIZE)" edit set image controller=${IMG}
|
|
"$(KUSTOMIZE)" build config/default > dist/install.yaml
|