-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
93 lines (78 loc) · 2.35 KB
/
Makefile
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
83
84
85
86
87
88
89
90
91
92
93
PROJECT_VERSION = 0.0.9
DEFAULT_REGISTRY_SERVER = k8s-registry.internal
DEFAULT_REGISTRY_USER = invtable
DEFAULT_REGISTRY_PASS = secret123
DEFAULT_REGISTRY_SECURED = true
DEFAULT_REGISTRY_PORT = 443
DEFAULT_DRY_RUN_MODE = false
DEFAULT_GC_MODE = true
BUILD_ARGS =
# Registry server, default k8s-registry.internal
ifneq ($(strip $(REGISTRY_SERVER)),)
BUILD_ARGS += registry_server: $(REGISTRY_SERVER);
else
REGISTRY_SERVER = $(DEFAULT_REGISTRY_SERVER)
BUILD_ARGS += registry_server: $(REGISTRY_SERVER);
endif
# Registry credentials
ifneq ($(strip $(REGISTRY_USER)),)
BUILD_ARGS += registry_username: $(REGISTRY_USER);
else
REGISTRY_USER = $(DEFAULT_REGISTRY_USER)
BUILD_ARGS += registry_username: $(REGISTRY_USER);
endif
ifneq ($(strip $(REGISTRY_PASS)),)
BUILD_ARGS += registry_password: $(REGISTRY_PASS);
else
REGISTRY_PASS = $(DEFAULT_REGISTRY_PASS)
BUILD_ARGS += registry_password: $(REGISTRY_PASS);
endif
# Registry lifecycle parameters
ifneq ($(strip $(REGISTRY_PORT)),)
BUILD_ARGS += registry_port: $(REGISTRY_PORT);
else
REGISTRY_PORT = $(DEFAULT_REGISTRY_PORT)
BUILD_ARGS += registry_port: $(REGISTRY_PORT);
endif
ifeq ($(REGISTRY_SECURED), true)
BUILD_ARGS += registry_secured: true;
else
REGISTRY_SECURED = $(DEFAULT_REGISTRY_SECURED)
BUILD_ARGS += registry_secured: $(REGISTRY_SECURED);
endif
DEBUG_LEVEL =
ifneq ($(strip $(DEBUG_LEVEL)),)
DEBUG_LEVEL = $(DEBUG_LEVEL)
endif
ifeq ($(strip $(ANSIBLE_USER)),)
ANSIBLE_USER = vagrant
endif
DRY_RUN_MODE := dry_run_mode: $(DEFAULT_DRY_RUN_MODE)
ifneq ($(strip $(DRY_RUN)),)
DRY_RUN_MODE := dry_run_mode: $(DRY_RUN)
endif
GC_MODE := garbage_collector_enabled: $(DEFAULT_GC_MODE)
ifneq ($(strip $(GARBAGE_COLLECT)),)
GC_MODE := garbage_collector.enabled: $(GARBAGE_COLLECT)
endif
.PHONY: registry regclean
all: prepare registry
prepare:
echo "---" > _environment.yml
echo "$(BUILD_ARGS)"|tr ";" "\n"|sed 's/\ //g'|sed 's/\:/\:\ /g' >> _environment.yml
echo "$(DRY_RUN_MODE)" >> _environment.yml
echo "$(GC_MODE)" >> _environment.yml
echo "" >> _environment.yml
build:
docker build -t devops-tools/registry-builder .
registry: prepare
vagrant up --no-provision
vagrant provision
provision: prepare
vagrant provision
status:
vagrant status
purge:
vagrant destroy -f
regclean: prepare
ansible-playbook $(DEBUG_LEVEL) --forks=10 -i inventory --limit=registry -e "@_environment.yml" cleaner.yaml