forked from aviacommerce/avia
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
126 lines (102 loc) · 2.91 KB
/
Makefile
File metadata and controls
126 lines (102 loc) · 2.91 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
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
.PHONY: \
dev \
test \
compile \
check-compile \
check-release \
check-migrations \
check-ci \
reset-db \
seed-db \
demo-db \
devstack \
devstack-build \
devstack-clean \
devstack-shell \
devstack-run \
DEFAULT_GOAL: help
export LOCAL_USER_ID ?= $(shell id -u $$USER)
export DOCKER_BUILDKIT=1
# -------------------
# --- DEFINITIONS ---
# -------------------
require-%:
@ if [ "${${*}}" = "" ]; then \
echo "ERROR: Environment variable not set: \"$*\""; \
exit 1; \
fi
# -----------------
# --- MIX TASKS ---
# -----------------
dev:
mix cmd --app snitch_core mix ecto.setup && iex -S mix phx.server
test:
mix test
compile:
@mix do deps.get, compile --warnings-as-errors
check-compile: compile
@MIX_ENV=test mix compile --warnings-as-errors
@mix format --check-formatted
@mix credo list
check-migrations:
@MIX_ENV=test mix ecto.reset
@MIX_ENV=test mix ecto.rollback.all
@MIX_ENV=test mix ecto.migrate
check-release:
@MIX_ENV=test mix release --overwrite
@DATABASE_URL="postgres://postgres:postgres:@db/snitch_dev" _build/test/rel/nue/bin/migrate_all.sh
check-ci: check-compile test check-migrations check-release
reset-db:
mix cmd --app snitch_core mix ecto.reset
demo-db: reset-db
mix cmd --app snitch_core mix ecto.seed && \
mix cmd --app snitch_core mix elasticsearch.build products --cluster Snitch.Tools.ElasticsearchCluster && \
mix cmd --app snitch_core mix ecto.load.demo
# -----------------------
# --- DOCKER DEVSTACK ---
# -----------------------
## Builds the development Docker image
devstack-build:
@docker build \
--target build \
--ssh default .\
--build-arg MIX_ENV=dev \
--build-arg APP_NAME=nue \
--tag nue:latest
## Stops all development containers
devstack-clean:
@docker-compose down -v
## Starts all development containers in the foreground
devstack: devstack-build
@docker-compose up
## Spawns an interactive Bash shell in development web container
devstack-shell:
@docker exec -e COLUMNS="`tput cols`" -e LINES="`tput lines`" -u ${LOCAL_USER_ID} -it $$(docker-compose ps -q web) /bin/bash -c "reset -w && /bin/bash"
## Starts the development server inside docker
devstack-run: devstack-build
@docker-compose up -d &&\
docker-compose exec web mix deps.get && \
docker-compose exec web mix ecto.setup && \
docker-compose exec web iex -S mix phx.server
prodstack-build:
@docker build \
--target release \
--ssh default .\
--build-arg MIX_ENV=prod \
--build-arg APP_NAME=nue \
--tag nue:release
# ------------
# --- HELP ---
# ------------
## Shows the help menu
help:
@echo "Please use \`make <target>' where <target> is one of\n\n"
@awk '/^[a-zA-Z\-\_\/0-9]+:/ { \
helpMessage = match(lastLine, /^## (.*)/); \
if (helpMessage) { \
helpCommand = substr($$1, 0, index($$1, ":")); \
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
printf "%-30s %s\n", helpCommand, helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)