|
49 | 49 | # Set the Operator SDK version to use. By default, what is installed on the system is used. |
50 | 50 | # This is useful for CI or a project to utilize a specific version of the operator-sdk toolkit. |
51 | 51 | OPERATOR_SDK_VERSION ?= v1.42.2 |
| 52 | + |
| 53 | +# Get git commit hash for tagging |
| 54 | +GIT_COMMIT ?= $(shell git rev-parse --short=7 HEAD) |
| 55 | + |
52 | 56 | # Image URL to use all building/pushing image targets |
53 | 57 | IMG ?= $(IMAGE_TAG_BASE):$(VERSION) |
| 58 | +IMG_COMMIT ?= $(IMAGE_TAG_BASE):$(GIT_COMMIT) |
54 | 59 |
|
55 | 60 | # Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) |
56 | 61 | ifeq (,$(shell go env GOBIN)) |
@@ -138,12 +143,13 @@ run: manifests generate fmt vet ## Run a controller from your host. |
138 | 143 | # (i.e. docker build --platform linux/arm64). However, you must enable docker buildKit for it. |
139 | 144 | # More info: https://docs.docker.com/develop/develop-images/build_enhancements/ |
140 | 145 | .PHONY: docker-build |
141 | | -docker-build: ## Build docker image with the manager. |
142 | | - $(CONTAINER_TOOL) build -t ${IMG} . |
| 146 | +docker-build: ## Build docker image with the manager, tagged with both VERSION and commit hash. |
| 147 | + $(CONTAINER_TOOL) build -t ${IMG} -t ${IMG_COMMIT} . |
143 | 148 |
|
144 | 149 | .PHONY: docker-push |
145 | | -docker-push: ## Push docker image with the manager. |
| 150 | +docker-push: ## Push docker image with the manager (both VERSION and commit hash tags). |
146 | 151 | $(CONTAINER_TOOL) push ${IMG} |
| 152 | + $(CONTAINER_TOOL) push ${IMG_COMMIT} |
147 | 153 |
|
148 | 154 | # PLATFORMS defines the target platforms for the manager image be built to provide support to multiple |
149 | 155 | # architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to: |
|
0 commit comments