-
Notifications
You must be signed in to change notification settings - Fork 14
/
docker.mk
67 lines (54 loc) · 1.8 KB
/
docker.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
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# Managed by makego. DO NOT EDIT.
# Must be set
$(call _assert_var,MAKEGO)
$(call _conditional_include,$(MAKEGO)/base.mk)
# Must be set
$(call _assert_var,PROJECT)
# Must be set
$(call _assert_var,GO_MODULE)
# Must be set
$(call _assert_var,DOCKER_ORG)
# Must be set
$(call _assert_var,DOCKER_PROJECT)
DOCKER_WORKSPACE_IMAGE := $(DOCKER_ORG)/$(DOCKER_PROJECT)-workspace
DOCKER_WORKSPACE_FILE := Dockerfile.workspace
DOCKER_WORKSPACE_DIR := /workspace
# Settable
DOCKER_BINS ?=
# Settable
DOCKER_BUILD_EXTRA_FLAGS ?=
# Runtime
DOCKERMAKETARGET ?= all
.PHONY: dockerbuildworkspace
dockerbuildworkspace:
docker build \
$(DOCKER_BUILD_EXTRA_FLAGS) \
--build-arg PROJECT=$(PROJECT) \
--build-arg GO_MODULE=$(GO_MODULE) \
-t $(DOCKER_WORKSPACE_IMAGE) \
-f $(DOCKER_WORKSPACE_FILE) \
.
.PHONY: dockermakeworkspace
dockermakeworkspace: dockerbuildworkspace
docker run -v "$(CURDIR):$(DOCKER_WORKSPACE_DIR)" $(DOCKER_WORKSPACE_IMAGE) make -j 8 $(DOCKERMAKETARGET)
.PHONY: dockerbuild
dockerbuild::
define dockerbinfunc
.PHONY: dockerbuilddeps$(1)
dockerbuilddeps$(1)::
.PHONY: dockerbuild$(1)
dockerbuild$(1): dockerbuilddeps$(1)
docker build $(DOCKER_BUILD_EXTRA_FLAGS) -t $(DOCKER_ORG)/$(1):latest -f Dockerfile.$(1) .
ifdef EXTRA_DOCKER_ORG
docker tag $(DOCKER_ORG)/$(1):latest $(EXTRA_DOCKER_ORG)/$(1):latest
endif
dockerbuild:: dockerbuild$(1)
endef
$(foreach dockerbin,$(sort $(DOCKER_BINS)),$(eval $(call dockerbinfunc,$(dockerbin))))
.PHONY: updatedockerignores
updatedockerignores:
@rm -f .dockerignore
@echo '# Autogenerated by makego. DO NOT EDIT.' > .dockerignore
@$(foreach file_ignore,$(sort $(FILE_IGNORES)),echo $(file_ignore) >> .dockerignore || exit 1;)
@$(foreach docker_file_ignore,$(sort $(DOCKER_FILE_IGNORES)),echo $(docker_file_ignore) >> .dockerignore || exit 1;)
pregenerate:: updatedockerignores