-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
133 lines (108 loc) · 3.41 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
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
# First target in the Makefile is the default.
all: help
# without this 'source' won't work.
SHELL := /bin/bash
# Get the location of this makefile.
ROOT_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
# Specify the binary dependencies
REQUIRED_BINS := docker docker-compose gcloud
$(foreach bin,$(REQUIRED_BINS),\
$(if $(shell command -v $(bin) 2> /dev/null),$(),$(error Please install `$(bin)` first!)))
.PHONY : help
help : Makefile
@sed -n 's/^##//p' $<
## up : Start Node
.PHONY : up
up: build-config yarn build
docker-compose up -d --no-build
## down : Shutdown Node
.PHONY : down
down:
docker-compose down
## restart : Restart Node
.PHONY : restart
restart: down up
## logs : Tail Node logs
.PHONY : logs
logs:
docker-compose logs -f -t | grep chainpoint-node
## logs-redis : Tail Redis logs
.PHONY : logs-redis
logs-redis:
docker-compose logs -f -t | grep redis
## logs-postgres : Tail PostgreSQL logs
.PHONY : logs-postgres
logs-postgres:
docker-compose logs -f -t | grep postgres
## logs-all : Tail all logs
.PHONY : logs-all
logs-all:
docker-compose logs -f -t
## ps : View running processes
.PHONY : ps
ps:
docker-compose ps
## build : Build Node image
.PHONY : build
build: tor-exit-nodes
docker build -t chainpoint-node .
docker tag chainpoint-node gcr.io/chainpoint-registry/github-chainpoint-chainpoint-ntpd
docker container prune -f
docker-compose build
## build-config : Copy the .env config from .env.sample
.PHONY : build-config
build-config:
@[ ! -f ./.env ] && \
cp .env.sample .env && \
echo 'Copied config .env.sample to .env' || true
## pull : Pull Docker images
.PHONY : pull
pull:
docker-compose pull
## git-pull : Git pull latest
.PHONY : git-pull
git-pull:
@git pull --all
## upgrade : Same as `make down && git pull && make up`
.PHONY : upgrade
upgrade: down git-pull up
## clean : Shutdown and **destroy** all local Node data
.PHONY : clean
clean: down
@rm -rf ./.data/*
## yarn : Install Node Javascript dependencies
.PHONY : yarn
yarn:
docker run -it --rm --volume "$(PWD)":/usr/src/app --volume /var/run/docker.sock:/var/run/docker.sock --volume ~/.docker:/root/.docker --volume "$(PWD)":/wd --workdir /wd gcr.io/chainpoint-registry/chainpoint-node:latest yarn
## postgres : Connect to the local PostgreSQL with `psql`
.PHONY : postgres
postgres:
@docker-compose up -d postgres
@sleep 6
@docker exec -it postgres-node-src psql -U chainpoint
## redis : Connect to the local Redis with `redis-cli`
.PHONY : redis
redis:
@docker-compose up -d redis
@sleep 2
@docker exec -it redis-node-src redis-cli
## backup-auth-keys : Backup all auth keys to the keys/backups dir
.PHONY : backup-auth-keys
backup-auth-keys:
@docker exec -it chainpointnodesrc_chainpoint-node_1 node auth-keys-backup-script.js
## calendar-delete : Delete all calendar data for this Node
.PHONY : calendar-delete
calendar-delete:
@docker-compose up -d postgres
@sleep 6
@docker exec -it postgres-node-src psql -U chainpoint -c "DELETE FROM calendar"
make restart
guard-%:
@ if [ "${${*}}" = "" ]; then \
echo "Environment variable $* not set"; \
exit 1; \
fi
## tor-exit-nodes : Update static list of Exit Nodes
.PHONY : tor-exit-nodes
tor-exit-nodes:
curl -s https://check.torproject.org/exit-addresses | grep ExitAddress | cut -d' ' -f2 > ./tor-exit-nodes.txt