forked from bitbeen/lisk-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
86 lines (63 loc) · 2 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
.PHONY: all clean release logs mrproper
EXPECTED_NODEJS_VERSION := $(shell cat .nvmrc)
RUNNING_NODEJS_VERSION := $(shell node --version)
ifneq ($(RUNNING_NODEJS_VERSION),v$(EXPECTED_NODEJS_VERSION))
$(error Wrong Node.js version: $(RUNNING_NODEJS_VERSION) (expected: v$(EXPECTED_NODEJS_VERSION)))
endif
CORE_VERSION := $(shell jq --raw-output .version package.json)
ifneq ($(findstring alpha,$(CORE_VERSION)),)
CORE_CHANNEL := alpha
else ifneq ($(findstring beta,$(CORE_VERSION)),)
CORE_CHANNEL := beta
else ifneq ($(findstring rc,$(CORE_VERSION)),)
CORE_CHANNEL := rc
else ifneq ($(findstring canary,$(CORE_VERSION)),)
CORE_CHANNEL := canary
endif
all: node_modules dist/index.js release
package-lock.json:
git checkout package-lock.json
touch -r npm-shrinkwrap.json package-lock.json
npm-shrinkwrap.json: package-lock.json
cp -f package-lock.json npm-shrinkwrap.json
node_modules: npm-shrinkwrap.json
npm ci
dist/index.js: node_modules
npm run build
ifndef $(CORE_VERSION)
release: dist/channels/$(CORE_CHANNEL)/lisk-core-v$(CORE_VERSION)
dist/channels/$(CORE_CHANNEL)/lisk-core-v$(CORE_VERSION):
npx oclif-dev pack --targets=linux-x64,darwin-x64
else
release: dist/lisk-core-v$(CORE_VERSION)
dist/lisk-core-v$(CORE_VERSION):
npx oclif-dev pack --targets=linux-x64,darwin-x64
endif
build: build-image build-local
build-image:
docker build -f ./docker/Dockerfile --build-arg NODEJS_VERSION=$(shell cat .nvmrc) --tag=lisk/core .
build-local:
npm ci
npm run build
clean: clean-image clean-local
clean-image:
docker rmi lisk/core; :
clean-local:
rm -rf dist/ node_modules/
# Usage: make start ARGS="-n mainnet -l debug"
start: check-args
docker run -d -p 7887:7887 -p 7667:7667 --name lisk-core --rm lisk/core start $(ARGS)
stop:
docker stop lisk-core; :
logs:
docker logs lisk-core
logs-live:
docker logs lisk-core --follow
# Usage: make run ARGS="start --help"
run: check-args
docker run --name lisk-core-temp --rm lisk/core $(ARGS)
check-args:
ifndef ARGS
$(error ARGS is undefined)
endif
mrproper: stop clean