Skip to content

Commit

Permalink
finish makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
maciaszczykm committed Dec 18, 2023
1 parent bd83278 commit a032686
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions controller/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ ifeq (,$(findstring $(GOPATH)/bin,$(PATH)))
$(error $$GOPATH/bin directory is not in your $$PATH)
endif

.PHONY: all
all: build

##@ General

.PHONY: help
Expand Down Expand Up @@ -59,12 +62,32 @@ run: manifests generate fmt vet ## run a controller from your host
release: manifests generate fmt vet ## builds release version of the app. Requires GoReleaser to work.
goreleaser build --clean --single-target --snapshot

docker-build: ## build Docker image with the driver
# 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/
docker-build: ## build Docker image with the manager
docker build --no-cache -t ${IMG} .

docker-push: ## push Docker image with the driver
docker-push: ## push docker image with the manager
docker 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/arm64,linux/amd64,linux/s390x,linux/ppc64le
.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
- docker buildx create --name project-v3-builder
docker buildx use project-v3-builder
- docker buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross .
- docker buildx rm project-v3-builder
rm Dockerfile.cross

##@ Codegen

.PHONY: manifests
Expand Down

0 comments on commit a032686

Please sign in to comment.