-
Notifications
You must be signed in to change notification settings - Fork 2
/
docker-targets.mk
27 lines (23 loc) · 1.04 KB
/
docker-targets.mk
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
_DOCKER_TARGETS_MK_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
include $(_DOCKER_TARGETS_MK_DIR)/version.mk
include $(_DOCKER_TARGETS_MK_DIR)/newline.mk
ifeq ($(CONTAINER_REPOSITORIES)$(OSS_CONTAINER_REGISTRY_HOSTS),)
docker-push:
$(error CONTAINER_REPOSITORIES or OSS_CONTAINER_REGISTRY_HOSTS must be provided as a space-separated lists of hosts/registry urls)
else ifneq ($(VERSION), $(VERSION:-dirty=))
docker-push:
$(error Refusing to push dirty image $(VERSION))
else
docker-push: docker-build ## Push container image
$(foreach host,$(CONTAINER_REPOSITORIES) $(OSS_CONTAINER_REGISTRY_HOSTS),$(call docker-push-to-registry,$(host)))
define docker-push-to-registry
docker tag ${IMG} $(1)/${IMG}$(NEWLINE)
docker push $(1)/${IMG}$(NEWLINE)
docker tag ${IMG}:${VERSION} $(1)/${IMG}:${VERSION}$(NEWLINE)
docker push $(1)/${IMG}:${VERSION}$(NEWLINE)
endef
endif
docker-build: GOOS=linux
docker-build: GOARCH=amd64
docker-build: build ## Build container image
docker build ${DOCKER_BUILD_EXTRA_PARAMS} -t ${IMG} -t ${IMG}:${VERSION} -f Dockerfile .