-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
105 lines (78 loc) · 2.93 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
## ~> GENERAL <~ ##
#####################
elm-package=$(shell pwd)/aion/node_modules/elm/binwrappers/elm-package
help: ## Print out this message
@IFS=$$'\n' ; \
help_lines=(`fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//'`); \
for help_line in $${help_lines[@]}; do \
IFS=$$'#' ; \
help_split=($$help_line) ; \
help_command=`echo $${help_split[0]} | sed -e 's/^ *//' -e 's/ *$$//'` ; \
help_info=`echo $${help_split[2]} | sed -e 's/^ *//' -e 's/ *$$//'` ; \
printf "%-30s %s\n" $$help_command $$help_info ; \
done
install-hooks: ## Install git hooks
cp scripts/hooks/* .git/hooks/
clean: ## Remove local files
rm -rf aion/deps
rm -rf aion/web/elm/elm-stuff
rm -rf aion/node_modules
test: ## Run tests
cd aion && mix test
lint: ## Run elixir linter
cd aion && mix credo --strict
reinstall-elm: ## Remove and reinstall elm dependencies
cd aion/web/elm && rm -rf elm-stuff && $(elm-package) install -y
#######################
## ~> DOCKER PART <~ ##
#######################
docker-build: ## Build docker image
@docker-compose down
@docker-compose up --build -d
@docker-compose run aion mix ecto.create
@docker-compose run aion mix ecto.migrate
docker-start: ## Run docker container
@docker-compose up
docker-stop: ## Stop docker container
@docker-compose down
##################################
## ~> LOCAL DEVELOPMENT PART <~ ##
##################################
development: local-deps local-db start-dev
development: ## Setup and run the whole project
start-dev: ## Start the phoenix server
cd aion && iex -S mix phoenix.server
local-db: ## Create and migrate db locally
cd aion && mix ecto.create && mix ecto.migrate
local-deps: ## Download all needed dependencies
cd aion && mix deps.get && npm install && cd web/elm && $(elm-package) install -y
##################################
## ~> DATABASE SEEDING PART <~ ##
##################################
populate-database: ## Seed database with fixtures prepared in fixtures/jpks/
populate-database:
cd fixtures && python3 main.py
populate-rooms: ## Create a set of rooms aggregating all the questions present in the database
populate-rooms:
cd fixtures && python3 main.py --rooms
##################################
## ~> DEPLOYMENT PART <~ ##
##################################
deploy-stop:
cd aion && sudo rel/aion/bin/aion stop
deploy-start:
cd aion && sudo rel/aion/bin/aion start
deploy-restart:
cd aion && sudo rel/aion/bin/aion restart
deploy: ## Create a release and run the production server
cd aion && \
MIX_ENV=prod mix do deps.get, compile && \
npm install && \
brunch build --production && \
MIX_ENV=prod mix phoenix.digest
# Try to shutdown running server, continue regardless
@-sudo ./aion/rel/aion/bin/aion stop && \
([ $$? -eq 0 ] && echo "Successfully stopped running server") || \
echo "Couldn't shut down the server, apparently it was not running"
cd aion && MIX_ENV=prod mix release
sudo ./aion/rel/aion/bin/aion start