forked from novalabsxyz/blockchain-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
101 lines (72 loc) · 2.29 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
.PHONY: all compile clean release devrelease test
APP_NAME ?= `grep 'app:' mix.exs | sed -e 's/\[//g' -e 's/ //g' -e 's/app://' -e 's/[:,]//g'`
APP_VSN ?= `grep 'version:' mix.exs | cut -d '"' -f2`
BUILD ?= `git rev-parse --short HEAD`
MIX=$(shell which mix)
all: set_rebar set_hex deps compile
set_hex:
mix local.hex --force
set_rebar:
mix local.rebar rebar3 ./rebar3 --force
deps:
mix deps.get
compile:
$(MIX) compile
clean:
$(MIX) clean
# Dev targets
devrelease:
export MIX_ENV=dev && $(MIX) distillery.release --env=dev
dev-start:
./_build/dev/rel/blockchain_api/bin/blockchain_api start
dev-foreground:
./_build/dev/rel/blockchain_api/bin/blockchain_api foreground
dev-console:
./_build/dev/rel/blockchain_api/bin/blockchain_api console
reset-dev-db:
export MIX_ENV=dev && $(MIX) ecto.reset
# Pescadero targets
pescadero-release:
export MIX_ENV=pescadero && $(MIX) distillery.release --env=pescadero
pescadero-start:
./_build/pescadero/rel/blockchain_api/bin/blockchain_api start
pescadero-foreground:
./_build/pescadero/rel/blockchain_api/bin/blockchain_api foreground
pescadero-console:
./_build/pescadero/rel/blockchain_api/bin/blockchain_api console
reset-pescadero-db:
export MIX_ENV=pescadero && $(MIX) ecto.reset
# Prod targets
release:
export NO_ESCRIPT=1 MIX_ENV=prod && $(MIX) distillery.release --env=prod
reset-prod-db:
export MIX_ENV=prod && $(MIX) ecto.reset
prod-interactive:
iex -S mix phx.server
prod-start:
./_build/prod/rel/blockchain_api/bin/blockchain_api start
prod-foreground:
./_build/prod/rel/blockchain_api/bin/blockchain_api foreground
prod-console:
./_build/prod/rel/blockchain_api/bin/blockchain_api console
# Test targets
test:
export MIX_ENV=test PORT=4002 && $(MIX) test --trace
reset-test-db:
export MIX_ENV=test && $(MIX) ecto.reset
ci:
export MIX_ENV=test PORT=4002 && $(MIX) local.hex --force && $(MIX) local.rebar --force && $(MIX) deps.get && $(MIX) test --trace
# Build prod docker image
docker-prod:
docker build \
--build-arg APP_NAME=$(APP_NAME) \
--build-arg APP_VSN=$(APP_VSN) \
--build-arg MIX_ENV=prod \
-t helium/$(APP_NAME):prod-latest .
# Build dev docker image
docker-dev:
docker build \
--build-arg APP_NAME=$(APP_NAME) \
--build-arg APP_VSN=$(APP_VSN) \
--build-arg MIX_ENV=dev \
-t helium/$(APP_NAME):dev-latest .