# Get the current Git commit hash GIT_COMMIT := $(shell git rev-parse --short HEAD) # Get the current date in YYYYMMDD format DATE_TAG := $(shell date +%Y%m%d) # Set the Docker image name and repository information IMAGE_NAME := almalinux8 REGISTRY := git.query.consul OWNER := unkin # Build the Docker image (without tags) build: docker build --network=host -t $(IMAGE_NAME) . # Tag the Docker image with the Git commit hash, the date, and 'latest' tag: docker tag $(IMAGE_NAME):latest $(REGISTRY)/$(OWNER)/$(IMAGE_NAME):$(GIT_COMMIT) docker tag $(IMAGE_NAME):latest $(REGISTRY)/$(OWNER)/$(IMAGE_NAME):$(DATE_TAG) docker tag $(IMAGE_NAME):latest $(REGISTRY)/$(OWNER)/$(IMAGE_NAME):latest # Push the Docker image to a repository with all tags push: tag docker push $(REGISTRY)/$(OWNER)/$(IMAGE_NAME):$(GIT_COMMIT) docker push $(REGISTRY)/$(OWNER)/$(IMAGE_NAME):$(DATE_TAG) docker push $(REGISTRY)/$(OWNER)/$(IMAGE_NAME):latest # Clean up dangling Docker images clean: docker image prune -f # Default target default: build