-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
94 lines (78 loc) · 2.31 KB
/
Makefile
File metadata and controls
94 lines (78 loc) · 2.31 KB
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
.SILENT :
# Image name
USERNAME:=ncarlier
APPNAME:=keeper-core-api
env?=dev
# Compose files
COMPOSE_FILES?=-f docker-compose.yml
# Database
DB?=mongodb://mongo/keeper
# Include common Make tasks
root_dir:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
makefiles:=$(root_dir)/makefiles
include $(makefiles)/help.Makefile
include $(makefiles)/docker/compose.Makefile
all: help
# Get Docker binaries version
infos:
echo "Using $(shell docker --version)"
echo "Using $(shell docker-compose --version)"
.PHONY: infos
## Build Docker image
build:
docker build --rm -t $(USERNAME)/$(APPNAME) .
.PHONY: build
# Add app to the Docker stack
with-app:
$(eval COMPOSE_FILES += -f docker-compose.app.yml)
.PHONY: with-app
## Run the container in test mode
test: with-app
echo "Running tests..."
make compose-wait service=elasticsearch
CMD=test APP_DATABASE_URI=$(DB) docker-compose $(COMPOSE_FILES) up --no-deps --no-build --abort-on-container-exit --exit-code-from api api
.PHONY: test
## Using Elasticsearch as main database
with-elastic:
echo "Using Elsaticsearch as DB..."
$(eval DB=elasticsearch://elasticsearch:9200/keeper)
.PHONY: with-elastic
## Start required services
deploy: infos compose-up
.PHONY: up
## Stop all services
undeploy: compose-down-force
.PHONY: down
## Show services logs
logs: compose-logs
.PHONY: logs
## Install as a service (needs root privileges)
install: build
echo "Install as a service..."
mkdir -p /var/opt/$(APPNAME)/storage/upload
mkdir -p /var/opt/$(APPNAME)/storage/exports
cp etc/systemd/system/* /etc/systemd/system/
cp etc/default/$(env).env /etc/default/$(APPNAME)
systemctl daemon-reload
systemctl enable $(APPNAME)
systemctl restart $(APPNAME)
systemctl enable keeper-core-job-worker
systemctl restart keeper-core-job-worker
systemctl enable keeper-data-backup.timer
systemctl restart keeper-data-backup.timer
$(MAKE) cleanup
.PHONY: install
## Un-install service (needs root privileges)
uninstall:
echo "Un-install service..."
systemctl stop keeper-data-backup.timer
systemctl disable keeper-data-backup.timer
systemctl stop keeper-core-job-worker
systemctl disable keeper-core-job-worker
systemctl stop $(APPNAME)
systemctl disable $(APPNAME)
rm /etc/systemd/system/keeper-core-*
rm /etc/default/$(APPNAME)
systemctl daemon-reload
$(MAKE) rm clean
.PHONY: uninstall