-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile.install
146 lines (121 loc) · 4.45 KB
/
Makefile.install
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# dcape install makefile
# this file used by dcape Makefile for `make install` and `make oauth-again` only
# ------------------------------------------------------------------------------
# Install variables
# most of them used once and does not saved to .env
# Token for client app registration
# Local gitea server will be used if empty
AUTH_TOKEN ?=
# External gitea URL
# Required if AUTH_TOKEN is not empty
# install will set to local url otherwise
AUTH_URL ?= $(AUTH_SERVER)
# Enable ACME (Let's Encrypt) certificates: [no]|http|wild
# http - use individual host cert
# wild - use wildcard domain for DCAPE_DOMAIN
ACME ?= no
# Enable powerdns on this host: [no]|yes|wild
# yes - just setup and start
# wild - use as wildcard domain nameserver
DNS ?= no
DCAPE_DB_REPO_NAME ?= postgres
DCAPE_NS_REPO_NAME ?= powerdns
DCAPE_VCS_REPO_NAME ?= gitea
DCAPE_ROUTER_REPO_NAME ?= traefik
DCAPE_CICD_REPO_NAME ?= woodpecker
DCAPE_AUTH_REPO_NAME ?= narra
DCAPE_CONFIG_REPO_NAME ?= enfist
DCAPE_MANAGER_REPO_NAME ?= portainer
DCAPE_REPO_BASE ?= https://github.com/dopos/dcape-app-
DCAPE_DB_REPO_URL ?= $(DCAPE_REPO_BASE)$(DCAPE_DB_REPO_NAME)
DCAPE_NS_REPO_URL ?= $(DCAPE_REPO_BASE)$(DCAPE_NS_REPO_NAME)
DCAPE_VCS_REPO_URL ?= $(DCAPE_REPO_BASE)$(DCAPE_VCS_REPO_NAME)
DCAPE_ROUTER_REPO_URL ?= $(DCAPE_REPO_BASE)$(DCAPE_ROUTER_REPO_NAME)
DCAPE_CICD_REPO_URL ?= $(DCAPE_REPO_BASE)$(DCAPE_CICD_REPO_NAME)
DCAPE_AUTH_REPO_URL ?= $(DCAPE_REPO_BASE)$(DCAPE_AUTH_REPO_NAME)
DCAPE_CONFIG_REPO_URL ?= $(DCAPE_REPO_BASE)$(DCAPE_CONFIG_REPO_NAME)
DCAPE_MANAGER_REPO_URL ?= $(DCAPE_REPO_BASE)$(DCAPE_MANAGER_REPO_NAME)
APPS_ALWAYS ?= auth config cicd manager
# ------------------------------------------------------------------------------
ifndef APPS
APPS += db
ifneq ($(DNS),no)
APPS += ns
endif
ifeq ($(ACME),no)
DCAPE_SCHEME := http
else
DCAPE_SCHEME := https
endif
APPS += router
ifndef AUTH_TOKEN
APPS += vcs
endif
APPS += $(APPS_ALWAYS)
endif
ifeq ($(AUTH_URL),)
ifndef AUTH_TOKEN
AUTH_URL := $(DCAPE_SCHEME)://git.$(DCAPE_DOMAIN)
else
$(error AUTH_URL required if AUTH_TOKEN is set)
endif
endif
# ------------------------------------------------------------------------------
$(DCAPE_VAR):
@mkdir -p $(DCAPE_VAR)
# download apps and create all of .env
init-all: $(CFG).sample $(DCAPE_VAR)
@for app in $(APPS); do \
echo -n "Installing $$app"; \
app_uc=$${app^^}; \
varname=DCAPE_$${app_uc}_REPO_NAME && name=$${!varname} ; \
varname=DCAPE_$${app_uc}_REPO_URL && url=$${!varname} ; \
echo " with $$name from $$url..." ; \
[ -d apps/$$name ] || git clone $$url apps/$$name ; \
[ -e apps/_$$app ] || ln -s $$name apps/_$$app ; \
[ ! -f apps/$$name/.env ] || continue ; \
pushd apps/$$name > /dev/null ; \
$(MAKE) -s config-if CFG=.env && $(MAKE) -s init CFG=.env ; \
popd > /dev/null ; \
done
@mv $(CFG).sample $(CFG)
$(MAKE) -s .env
# Prepare and Setup and run dcape apps
setup-all: APPS_DIRS = $(addprefix $(DCAPE_ROOT)/apps/_,$(APPS))
setup-all: DC_SOURCES = $(addsuffix /docker-compose.inc.yml,$(APPS_DIRS))
setup-all: .env docker-compose.yml .setup-app
# Setup and run dcape apps
.setup-app:
@for app in $(APPS); do \
echo "Setting $$app up..."; \
app_uc=$${app^^}; \
varname=DCAPE_$${app_uc}_REPO_NAME && name=$${!varname} ; \
varname=DCAPE_$${app_uc}_REPO_URL && url=$${!varname} ; \
pushd apps/$$name > /dev/null ; \
$(MAKE) -s .setup-before-up APP_ROOT=$(DCAPE_ROOT)/apps/$$name CFG=.env ; \
popd > /dev/null ; \
$(MAKE) -s up-$$app ; \
pushd apps/$$name > /dev/null ; \
$(MAKE) -s .setup-after-up APP_ROOT=$(DCAPE_ROOT)/apps/$$name CFG=.env || true ; \
popd > /dev/null ; \
done
# Install dcape
install: msg = Dcape install start
install: .stamp init-all setup-all ps
@$(MAKE) -s .stamp msg="Dcape install done"
install-minimal:
@echo "Not implemented. WIP"
install-minimal-acme:
@echo "Not implemented. WIP"
# Upgrade dcape to v3
upgrade-v3: msg = Dcape upgrade start
upgrade-v3: .stamp init-all
@$(MAKE) -s .stamp msg="Dcape upgrade done"
# Repeat OAuth apps linking
oauth-again:
@pushd apps/_vcs > /dev/null ; $(MAKE) -s token ; popd > /dev/null
@pushd apps/_auth > /dev/null ; $(MAKE) -s oauth2-create CFG=.env ; popd > /dev/null
@$(MAKE) -s reup-auth
@pushd apps/_cicd > /dev/null ; $(MAKE) -s oauth2-create CFG=.env ; popd > /dev/null
@$(MAKE) -s reup-cicd
# TODO: token-delete