-
Notifications
You must be signed in to change notification settings - Fork 26
/
Makefile.shipyard
82 lines (64 loc) · 2.54 KB
/
Makefile.shipyard
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# This Makefile contains the basic goals to set up a Shipyard based environment, which runs inside a container
, := ,
BASE_DAPPER := Dockerfile.dapper
USING = $(subst $(,), ,$(using))
LINTING_DAPPER := Dockerfile.linting
LINTING_GOALS := gitlint shellcheck yamllint markdownlint
NON_DAPPER_GOALS += .dapper shell targets $(LINTING_GOALS)
SHIPYARD_GOALS += cleanup clean-clusters clusters golangci-lint packagedoc-lint
export MAKEFLAGS
export USING
# Define LOCAL_BUILD to build directly on the host and not inside a Dapper container
ifdef LOCAL_BUILD
DAPPER_HOST_ARCH ?= $(shell go env GOHOSTARCH)
SHIPYARD_DIR ?= ../shipyard
SCRIPTS_DIR ?= $(SHIPYARD_DIR)/scripts/shared
export DAPPER_HOST_ARCH
export SHIPYARD_DIR
export SCRIPTS_DIR
RUN_IN_DAPPER :=
.dapper:
else
.dapper:
@echo Downloading dapper
@curl -sfLO $(SHIPYARD_URL)/$@
@chmod +x .dapper
@./.dapper -v
SELINUX_CONTEXT := $(shell (selinuxenabled && echo -S z) 2>/dev/null)
RUN_IN_DAPPER = ./.dapper $(DAPPER_ARGS) $(SELINUX_CONTEXT) --
endif
ifeq (true,$(DEBUG_PRINT))
MAKE_DEBUG_FLAG = --debug=b
endif
USING = $(subst $(,), ,$(using))
_using = ${USING}
ifneq (,$(filter dual-stack ipv6-stack,$(_using)))
IPV6_FLAGS = --ipv6 --subnet fc00:1234:4444::/64
endif
# Run only Shipyard goals inside the container when requested, otherwise run any suitable goal inside the container.
ifdef ONLY_SHIPYARD_GOALS
$(SHIPYARD_GOALS): .dapper $(BASE_DAPPER)
else
$(filter-out .dapper prune-images shell targets $(NON_DAPPER_GOALS),$(MAKECMDGOALS)): .dapper $(BASE_DAPPER)
endif
@[ -z "$$CI" ] || echo "::group::Launching a container to run 'make $@'"
-docker network create $(IPV6_FLAGS) -d bridge kind
+$(RUN_IN_DAPPER) make $(MAKE_DEBUG_FLAG) $@
# The original dockerfiles will live in Shipyard and be downloaded by consuming projects.
$(BASE_DAPPER) $(LINTING_DAPPER):
@echo Downloading $@
@curl -sfLO $(SHIPYARD_URL)/$@
# Run silently as the commands are pretty straightforward and `make` hasn't a lot to do
$(LINTING_GOALS): DAPPER_ARGS := -f $(LINTING_DAPPER)
$(LINTING_GOALS): .dapper $(LINTING_DAPPER)
@[ -z "$$CI" ] || echo "::group::Launching a container to run 'make $@'"
@$(RUN_IN_DAPPER) make $@
shell: DAPPER_ARGS := -s
shell: .dapper $(BASE_DAPPER)
$(RUN_IN_DAPPER)
# Run silently to just list the targets (hence we can't use the generic dapper wrapper recipe).
# This only lists targets accessible inside dapper (which are 99% of targets we use)
targets: DAPPER_ARGS := -f $(LINTING_DAPPER)
targets: $(LINTING_DAPPER)
@$(RUN_IN_DAPPER) eval "\$${SCRIPTS_DIR}/targets.sh"
.PHONY: shell targets $(LINTING_GOALS)