This repository has been archived by the owner on Apr 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
58 lines (46 loc) · 1.5 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
.SILENT :
.PHONY : test up down install
USERNAME:=ncarlier
APPNAME:=reader
env?=dev
# Default links
LINK_FLAGS?=--link redis:redis
# Default configuration
ENV_FLAGS?=--env-file="./etc/default/$(env).env" --env-file="./etc/default/custom.env"
# Custom run flags
RUN_CUSTOM_FLAGS?=-p 3000:3000 $(ENV_FLAGS) $(LINK_FLAGS)
# Docker configuartion regarding the system architecture
BASEIMAGE=node:4
UNAME_M := $(shell uname -m)
ifeq ($(UNAME_M),armv7l)
BASEIMAGE=ncarlier/nodejs-arm
endif
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
include $(ROOT_DIR)/dockerfiles/common/_Makefile
## Run the container in test mode
test:
echo "Running tests..."
$(DOCKER) run --rm -it $(RUN_CUSTOM_FLAGS) $(VOLUME_FLAGS) $(IMAGE) test
## Start a complete infrastucture
up:
echo "Starting Redis ..."
make -C $(ROOT_DIR)/dockerfiles/redis stop rm start
## Stop the infrastucture
down:
echo "Stoping Redis ..."
make -C $(ROOT_DIR)/dockerfiles/redis stop rm
## Install as a service (needs root privileges)
install: build
echo "Install as a service..."
cp etc/systemd/system/* /etc/systemd/system/
cp etc/default/$(env).env /etc/default/$(APPNAME)
systemctl daemon-reload
systemctl enable $(APPNAME)-server
systemctl restart $(APPNAME)-server
systemctl enable $(APPNAME)-feed-updater
systemctl restart $(APPNAME)-feed-updater
systemctl enable $(APPNAME)-timeline-updater
systemctl restart $(APPNAME)-timeline-updater
systemctl enable $(APPNAME)-cleandb
systemctl restart $(APPNAME)-cleandb
$(MAKE) cleanup