forked from paperwork/paperwork
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
41 lines (34 loc) · 2.55 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
# ╔════════════════════════════════════════════════════════════════════════════╗
# ║ ║
# ║ \ | | _|_) | ║
# ║ |\/ | _` | | / _ \ | | | _ \ ║
# ║ | | ( | < __/ __| | | __/ ║
# ║ _| _|\__,_|_|\_\\___|_| _|_|\___| ║
# ║ ║
# ║ * github.com/paperwork * twitter.com/paperworkcloud * ║
# ║ ║
# ╚════════════════════════════════════════════════════════════════════════════╝
.PHONY: help init deploy undeploy status
ORCHESTRATOR ?= swarm ##@Variables The Docker orchestrator to use, default: swarm
STACK_NAME ?= paperwork ##@Variables The Docker stack name, default: paperwork
COMPOSE_FILE ?= paperwork.yml ##@Variables The Docker stack compose file to use, default: paperwork.yml
FN_HELP = \
%help; while(<>){push@{$$help{$$2//'options'}},[$$1,$$3] \
if/^(\w+)\s*(?:).*\#\#(?:@(\w+))?\s(.*)$$/}; \
print"$$_:\n", map" $$_->[0]".(" "x(20-length($$_->[0])))."$$_->[1]\n",\
@{$$help{$$_}},"\n" for keys %help; \
help: ##@Miscellaneous Show this help
@echo "Usage: make [target] <var> ...\n"
@perl -e '$(FN_HELP)' $(MAKEFILE_LIST)
deploy: ##@Deployment Deploy Paperwork
(docker service ls || docker swarm init) \
&& env $(shell cat env/env.env | xargs) docker stack deploy --orchestrator=${ORCHESTRATOR} --prune --compose-file ${COMPOSE_FILE} ${STACK_NAME}
# docker stack ps --orchestrator=${ORCHESTRATOR} ${STACK_NAME} > /dev/null \
# && $(error Paperwork already deployed! Run `make undeploy` first.) \
# || docker stack deploy --orchestrator=${ORCHESTRATOR} --prune --compose-file ${COMPOSE_FILE} ${STACK_NAME}
undeploy: ##@Deployment Undeploy Paperwork
docker stack rm --orchestrator=${ORCHESTRATOR} ${STACK_NAME}
status: ##@Deployment Check Paperwork deployment status
docker stack ps --orchestrator=${ORCHESTRATOR} ${STACK_NAME}
local-run-develop: ##@Local Run local dev env
$(MAKE) all -C development