forked from elpaso/qgis-feed
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
200 lines (172 loc) · 8.95 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
CONTAINER_NAME := qgisfeed
SHELL := /bin/bash
# ----------------------------------------------------------------------------
# D E V E L O P M E N T C O M M A N D S
# ----------------------------------------------------------------------------
default: dev-build
run: dev-build dev-start
dev-build:
@echo
@echo "------------------------------------------------------------------"
@echo "Building in development mode"
@echo "------------------------------------------------------------------"
@docker compose -f docker-compose.dev.yml build
dev-start:
@echo
@echo "------------------------------------------------------------------"
@echo "Running in development mode"
@echo "------------------------------------------------------------------"
@docker-compose -f docker-compose.dev.yml up
dev-logs:
@echo
@echo "------------------------------------------------------------------"
@echo "Show the logs in development mode"
@echo "------------------------------------------------------------------"
@docker logs -f $(CONTAINER_NAME)
dev-update-migrations:
@echo
@echo "------------------------------------------------------------------"
@echo "Running makemigrations in development mode"
@echo "------------------------------------------------------------------"
@docker compose -f docker-compose.dev.yml exec $(CONTAINER_NAME) python qgisfeedproject/manage.py makemigrations
dev-migrate:
@echo
@echo "------------------------------------------------------------------"
@echo "Running migrate in development mode"
@echo "------------------------------------------------------------------"
@docker compose -f docker-compose.dev.yml exec $(CONTAINER_NAME) python qgisfeedproject/manage.py migrate
dev-dbseed:
@echo
@echo "------------------------------------------------------------------"
@echo "Seed db with JSON data from /fixtures/*.json"
@echo "------------------------------------------------------------------"
@docker compose -f docker-compose.dev.yml exec $(CONTAINER_NAME) python qgisfeedproject/manage.py loaddata qgisfeedproject/qgisfeed/fixtures/*.json
dev-createsuperuser:
@echo
@echo "------------------------------------------------------------------"
@echo "Create an admin user"
@echo "------------------------------------------------------------------"
@docker compose -f docker-compose.dev.yml exec $(CONTAINER_NAME) python qgisfeedproject/manage.py createsuperuser
dev-runtests:
@echo
@echo "------------------------------------------------------------------"
@echo "Running tests in development mode"
@echo "------------------------------------------------------------------"
@docker compose -f docker-compose.dev.yml exec $(CONTAINER_NAME) python qgisfeedproject/manage.py test qgisfeed
dev-stop:
@echo
@echo "------------------------------------------------------------------"
@echo "Stopping the development server"
@echo "------------------------------------------------------------------"
@docker compose -f docker-compose.dev.yml down
# ----------------------------------------------------------------------------
# P R O D U C T I O N C O M M A N D S
# ----------------------------------------------------------------------------
build:
@echo
@echo "------------------------------------------------------------------"
@echo "Building in production mode"
@echo "------------------------------------------------------------------"
@docker compose -f docker-compose-production-ssl.yml build
start:
@echo
@echo "------------------------------------------------------------------"
@echo "Starting all or specific container(s) in production mode."
@echo "------------------------------------------------------------------"
@docker compose -f docker-compose-production-ssl.yml up -d $(c)
restart:
@echo
@echo "------------------------------------------------------------------"
@echo "Restarting all or specific container(s) in production mode."
@echo "------------------------------------------------------------------"
@docker compose -f docker-compose-production-ssl.yml up -d $(c)
kill:
@echo
@echo "------------------------------------------------------------------"
@echo "Killing all or a specific container(s) in production mode"
@echo "------------------------------------------------------------------"
@docker compose -f docker-compose-production-ssl.yml kill $(c)
dbrestore:
@echo
@echo "------------------------------------------------------------------"
@echo "Restore dump from /backups/latest-qgisfeed.dmp and /backups/latest-metabase.dmp in production mode"
@echo "------------------------------------------------------------------"
@echo "stopping qgisfeed container"
@docker compose -f docker-compose-production-ssl.yml stop qgisfeed
@echo "Dropping the gis and metabase databases"
-@docker compose -f docker-compose-production-ssl.yml exec postgis su - postgres -c "dropdb --force qgisfeed"
-@docker compose -f docker-compose-production-ssl.yml exec postgis su - postgres -c "dropdb --force metabase"
@echo "Creating the qgisfeed and metabase databases"
-@docker compose -f docker-compose-production-ssl.yml exec postgis su - postgres -c "createdb -O docker -T template1 qgisfeed"
-@docker compose -f docker-compose-production-ssl.yml exec postgis su - postgres -c "createdb -O docker -T template1 metabase"
@echo "Restore database from backups/latest-qgisfeed.dmp and backups/latest-metabase.dmp"
@docker compose -f docker-compose-production-ssl.yml exec postgis su - postgres -c "pg_restore -c /backups/latest-qgisfeed.dmp -d qgisfeed"
@docker compose -f docker-compose-production-ssl.yml exec postgis su - postgres -c "pg_restore -c /backups/latest-metabase.dmp -d metabase"
@echo "Starting qgisfeed container"
@docker compose -f docker-compose-production-ssl.yml up -d qgisfeed
updatemigrations:
@echo
@echo "------------------------------------------------------------------"
@echo "Running in production mode"
@echo "------------------------------------------------------------------"
@docker compose -f docker-compose-production-ssl.yml exec $(CONTAINER_NAME) python qgisfeedproject/manage.py makemigrations
migrate:
@echo
@echo "------------------------------------------------------------------"
@echo "Running migrate in production mode"
@echo "------------------------------------------------------------------"
@docker compose -f docker-compose-production-ssl.yml exec $(CONTAINER_NAME) python qgisfeedproject/manage.py migrate
createsuperuser:
@echo
@echo "------------------------------------------------------------------"
@echo "Create an admin user"
@echo "------------------------------------------------------------------"
@docker compose -f docker-compose-production-ssl.yml exec $(CONTAINER_NAME) python qgisfeedproject/manage.py createsuperuser
collectstatic:
@echo
@echo "------------------------------------------------------------------"
@echo "Collecting static in production mode"
@echo "------------------------------------------------------------------"
@docker compose -f docker-compose-production-ssl.yml exec $(CONTAINER_NAME) python qgisfeedproject/manage.py collectstatic --noinput
qgisfeed-shell:
@echo
@echo "------------------------------------------------------------------"
@echo "Shelling into the qgisfeed container"
@echo "------------------------------------------------------------------"
@docker compose -f docker-compose-production-ssl.yml exec qgisfeed bash
qgisfeed-logs:
@echo
@echo "------------------------------------------------------------------"
@echo "Show the qgisfeed container logs"
@echo "------------------------------------------------------------------"
@docker compose -f docker-compose-production-ssl.yml logs -f qgisfeed
nginx-shell:
@echo
@echo "------------------------------------------------------------------"
@echo "Shelling into the nginx container"
@echo "------------------------------------------------------------------"
@docker compose -f docker-compose-production-ssl.yml exec nginx bash
nginx-logs:
@echo
@echo "------------------------------------------------------------------"
@echo "Show the nginx container logs"
@echo "------------------------------------------------------------------"
@docker compose -f docker-compose-production-ssl.yml logs -f nginx
logs:
@echo
@echo "------------------------------------------------------------------"
@echo "Tailing all logs or a specific container"
@echo "------------------------------------------------------------------"
@docker compose -f docker-compose-production-ssl.yml logs -f $(c)
shell:
@echo
@echo "------------------------------------------------------------------"
@echo "Shelling into a specific container"
@echo "------------------------------------------------------------------"
@docker compose -f docker-compose-production-ssl.yml exec $(c) bash
exec:
@echo
@echo "------------------------------------------------------------------"
@echo "Execute a specific docker command"
@echo "------------------------------------------------------------------"
@docker compose -f docker-compose-production-ssl.yml $(c)