-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
145 lines (108 loc) · 3.39 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
134
135
136
137
138
139
140
141
142
143
144
145
#
# Makefile for siderDB project
#
SHELL := bash
PID_FILE := /var/siderdb.pid
.DEFAULT_GOAL := help
.PHONY: help
help:
@echo ""
@echo "==> Manage application"
@echo "update_cpanlib Install CPAN libs"
@echo "update_db Deploy populate and dump schema for db"
@echo "deploy_db Deploy with Sqitch"
@echo "populate_db Populate db with toy dataset"
@echo "dump_schema_db Dump classes with dbicdump"
@echo "update Update deps and db"
@echo "server Start demo application server"
@echo "hup Restart demo application server"
@echo "dependencies List (most) CPAN dependencies"
@echo ""
@echo "==> Manage containers"
@echo "up Start containers"
@echo "stop Stop containers"
@echo "down Remove containers"
@echo "restart Restart containers"
@echo "build Rebuild containers"
@echo ""
@echo "==> Container internal commands"
@echo "app-shell Open a shell in the app container"
@echo "app-update 'make update' inside the app container"
@echo "app-hup 'make hup' inside the app container"
@echo "app-restart 'make update & make hup' inside the app container"
@echo "app-prove 'prove' inside the app container"
@echo "app-db-status 'sqitch' status inside the app container"
@echo "app-db-verify 'sqitch' verify inside the app container"
@echo "app-db-log 'sqitch' log inside the app container"
@echo "db-psql 'psql' inside the db container"
@echo "db-shell Open a shell in the db container"
@echo ""
# Manage application
.PHONY: update_cpanlib update_db deploy_db populate_db dump_schema_db update \
server hup server-stop dependencies
update_cpanlib:
@cpanm --quiet --notest --installdeps .
update_db: deploy_db populate_db dump_schema_db
deploy_db:
@sqitch deploy
populate_db:
@perl script/siderdb_populate.pl \
t/etc/schema.yml \
dbi:Pg:host=$$PGHOST,dbname=$$PGDATABASE \
$$PGUSER \
$$PGPASSWORD
dump_schema_db:
@dbicdump -o dump_directory=./lib \
siderDB::Schema \
dbi:Pg:host=$$PGHOST,dbname=$$PGDATABASE \
$$PGUSER \
$$PGPASSWORD
update: update_db update_cpanlib
server: update
@perl script/siderdb_server.pl --port=5000 --pidfile=$(PID_FILE)
hup:
@kill -HUP $$(cat $(PID_FILE));
server-stop:
@kill $$(cat $(PID_FILE));
dependencies:
@find . -type f -exec awk '/^use / {gsub(";","");print $$2}' '{}' \; \
| grep -v siderDB \
| sort -u
# Manage containers
.PHONY: up stop down restart build
up:
@docker-compose up -d
stop:
@docker-compose stop
down:
@docker-compose down
restart: stop up
build:
@docker-compose build
# Container internal commands
.PHONY: app-shell app-update app-hup app-server-stop app-server \
app-restart app-prove app-db-status app-db-verify \
app-db-log db-psql db-shell
app-shell:
@docker-compose exec app bash
app-update:
@docker-compose exec app make update
app-hup:
@docker-compose exec app make hup
app-server-stop:
@docker-compose exec app make server-stop
app-server:
@docker-compose exec app make server
app-restart: app-update app-hup
app-prove:
@docker-compose exec app prove -lvr $(filter-out app-prove,$(MAKECMDGOALS))
app-db-status:
@docker-compose exec app sqitch status
app-db-verify:
@docker-compose exec app sqitch verify
app-db-log:
@docker-compose exec app sqitch log
db-psql:
@docker-compose exec db psql
db-shell:
@docker-compose exec db bash