-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile.docker
52 lines (44 loc) · 1.54 KB
/
Makefile.docker
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Set docker BUILDKIT progress type.
DOCKER_BUILDKIT_PROGRESS := auto
# Set common utilities environs.
DOCKER_BIN := $(or $(DOCKER_BIN),docker)
SSH_ADD_BIN := $(or $(SSH_ADD_BIN),ssh-add)
# Build version variables.
BUILD_VERSION ?= $(shell $(GIT_BIN) describe --always --dirty --broken --abbrev=8)
# Default image name.
IMAGE_NAME ?= $(IMAGE_DEFAULT_NAME)
# Default image tag.
IMAGE_TAG ?= $(BUILD_VERSION)
# Docker build args for current project.
IMAGE_BUILD_ARGS = -f Dockerfile -t $(IMAGE_NAME):$(IMAGE_TAG) -t $(IMAGE_NAME):latest
ifdef DOCKER_BUILD_ARGS
IMAGE_BUILD_ARGS += $(foreach arg,$(DOCKER_BUILD_ARGS),--build-arg $(arg))
endif
# Docker build labels for current project.
IMAGE_BUILD_LABELS = --label io.k8s.version=$(BUILD_VERSION)
IMAGE_BUILD_LABELS += --label io.k8s.display-name=$(IMAGE_DISPLAY_NAME)
IMAGE_BUILD_LABELS += --label io.k8s.description=$(IMAGE_DESCRIPTION)
ifdef DOCKER_BUILD_LABELS
IMAGE_BUILD_LABELS += $(foreach arg,$(DOCKER_BUILD_LABELS),--label $(arg))
endif
# Print Docker environment configuration.
.PHONY: docker-info
docker-info:
@echo
@echo \# Current user information:
@$(ID_BIN)
@echo
@echo \# SSH-AGENT information:
@$(SSH_ADD_BIN) -L
@echo
@echo \# Docker version information:
@$(ENV_BIN) DOCKER_BUILDKIT=1 $(DOCKER_BIN) version
@echo
# Build docker image, set additional image tags.
.PHONY: docker
docker: docker-info
$(ENV_BIN) DOCKER_BUILDKIT=1 DOCKER_CONFIG=$(DOCKER_CONFIG) $(DOCKER_BIN) build \
--ssh default \
--progress=$(DOCKER_BUILDKIT_PROGRESS) \
$(IMAGE_BUILD_ARGS) \
$(IMAGE_BUILD_LABELS) .