-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdocker-targets.mk
More file actions
36 lines (31 loc) · 1.29 KB
/
docker-targets.mk
File metadata and controls
36 lines (31 loc) · 1.29 KB
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
_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
ifeq ($(CI),true)
DOCKER_CACHE_PARAMS = \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--cache-from $(firstword $(CONTAINER_REPOSITORIES) $(OSS_CONTAINER_REGISTRY_HOSTS))/${IMG}:latest
endif
docker-build: GOOS=linux
docker-build: GOARCH=amd64
docker-build: build ## Build container image
docker build ${DOCKER_BUILD_EXTRA_PARAMS} \
--platform ${GOOS}/${GOARCH} \
${DOCKER_CACHE_PARAMS} \
-t ${IMG} -t ${IMG}:${VERSION} -f Dockerfile .