-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
211 lines (180 loc) · 8.33 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
201
202
203
204
205
206
207
208
209
210
211
PROJECT_ID := rir_dashboard
export COMPOSE_FILE=deployment/docker-compose.yml:deployment/docker-compose.override.yml
export ONEDRIVE_DATA_DIR=$(shell pwd)/deployment/onedrive/data
SHELL := /bin/bash
# ----------------------------------------------------------------------------
# P R O D U C T I O N C O M M A N D S
# ----------------------------------------------------------------------------
default: web
run: build web collectstatic
deploy: run
@echo
@echo "------------------------------------------------------------------"
@echo "Bringing up fresh instance "
@echo "You can access it on http://localhost"
@echo "------------------------------------------------------------------"
web:
@echo
@echo "------------------------------------------------------------------"
@echo "Running in production mode"
@echo "------------------------------------------------------------------"
@docker-compose up -d
dev:
@echo
@echo "------------------------------------------------------------------"
@echo "Running in dev mode"
@echo "------------------------------------------------------------------"
@docker-compose ${ARGS} up -d dev
@docker-compose ${ARGS} up --no-recreate --no-deps -d
@docker exec $(PROJECT_ID)_dev python manage.py runserver 0.0.0.0:8080
dev-kill:
@echo
@echo "------------------------------------------------------------------"
@echo "Kill dev"
@echo "------------------------------------------------------------------"
@docker kill $(PROJECT_ID)_dev
dev-reload: dev-kill dev
@echo
@echo "------------------------------------------------------------------"
@echo "Reload DEV"
@echo "------------------------------------------------------------------"
build:
@echo
@echo "------------------------------------------------------------------"
@echo "Building in production mode"
@echo "------------------------------------------------------------------"
@docker-compose build
nginx:
@echo
@echo "------------------------------------------------------------------"
@echo "Running nginx in production mode"
@echo "Normally you should use this only for testing"
@echo "In a production environment you will typically use nginx running"
@echo "on the host rather if you have a multi-site host."
@echo "------------------------------------------------------------------"
@docker-compose up -d nginx
@echo "Site should now be available at http://localhost"
up: web
status:
@echo
@echo "------------------------------------------------------------------"
@echo "Show status for all containers"
@echo "------------------------------------------------------------------"
@docker-compose ps
kill:
@echo
@echo "------------------------------------------------------------------"
@echo "Killing in production mode"
@echo "------------------------------------------------------------------"
@docker-compose stop
down: kill
@echo
@echo "------------------------------------------------------------------"
@echo "Removing production instance!!! "
@echo "------------------------------------------------------------------"
@docker-compose down
shell:
@echo
@echo "------------------------------------------------------------------"
@echo "Shelling in in production mode"
@echo "------------------------------------------------------------------"
@docker-compose exec django /bin/bash
db-bash:
@echo
@echo "------------------------------------------------------------------"
@echo "Entering DB Bash in production mode"
@echo "------------------------------------------------------------------"
@docker-compose exec db sh
db-shell:
@echo
@echo "------------------------------------------------------------------"
@echo "Entering PostgreSQL Shell in production mode"
@echo "------------------------------------------------------------------"
docker-compose exec db su - postgres -c "psql"
collectstatic:
@echo
@echo "------------------------------------------------------------------"
@echo "Collecting static in production mode"
@echo "------------------------------------------------------------------"
#@docker-compose run django python manage.py collectstatic --noinput
#We need to run collect static in the same context as the running
# django container it seems so I use docker exec here
# no -it flag so we can run over remote shell
@docker exec $(PROJECT_ID)_django python manage.py collectstatic --noinput
reload:
@echo
@echo "------------------------------------------------------------------"
@echo "Reload django project in production mode"
@echo "------------------------------------------------------------------"
# no -it flag so we can run over remote shell
@docker exec $(PROJECT_ID)_django django --reload /tmp/django.pid
migrate:
@echo
@echo "------------------------------------------------------------------"
@echo "Running migrate static in production mode"
@echo "------------------------------------------------------------------"
@docker-compose exec django python manage.py migrate
onedrive-volume:
@echo
@echo "------------------------------------------------------------------"
@echo "Create volume"
@echo "------------------------------------------------------------------"
@docker volume create --name $(PROJECT_ID)_onedrive-conf
@docker volume rm $(PROJECT_ID)_onedrive-conf
@rm -rf ${ONEDRIVE_DATA_DIR}
@mkdir -p ${ONEDRIVE_DATA_DIR}
@docker volume create --name $(PROJECT_ID)_onedrive-conf
@docker run --name hello-world -v "$(PROJECT_ID)_onedrive-conf:/onedrive/conf" hello-world; docker cp deployment/onedrive/config hello-world:/onedrive/conf; docker rm hello-world
onedrive-firstrun: onedrive-volume
@echo
@echo "------------------------------------------------------------------"
@echo "First run one drive"
@echo "------------------------------------------------------------------"
@docker run -it --name onedrive -v $(PROJECT_ID)_onedrive-conf:/onedrive/conf -v "${ONEDRIVE_DATA_DIR}:/onedrive/data" -e "ONEDRIVE_UID=1000" -e "ONEDRIVE_GID=1000" -e "ONEDRIVE_RESYNC=1" driveone/onedrive:latest
# --------------- help --------------------------------
help:
@echo "* **build** - builds all required containers."
@echo "* **up** - runs all required containers."
@echo "* **kill** - kills all running containers. Does not remove them."
@echo "* **logs** - view the logs of all running containers. Note that you can also view individual logs in the deployment/logs directory."
@echo "* **nginx** - builds and runs the nginx container."
@echo "* **permissions** - Update the permissions of shared volumes. Note this will destroy any existing permissions you have in place."
@echo "* **rm** - remove all containers."
@echo "* **shell-frontend-mapstore** - open a bash shell in the frontend mapstore (where django runs) container."
# ----------------------------------------------------------------------------
# DEVELOPMENT C O M M A N D S
# --no-deps will attach to prod deps if running
# after running you will have ssh and web ports open (see dockerfile for no's)
# and you can set your pycharm to use the python in the container
# Note that pycharm will copy in resources to the /root/ user folder
# for pydevd etc. If they dont get copied, restart pycharm...
# ----------------------------------------------------------------------------
db:
@echo
@echo "------------------------------------------------------------------"
@echo "Running db in production mode"
@echo "------------------------------------------------------------------"
@docker-compose ${ARGS} up -d db
wait-db:
@docker-compose ${ARGS} exec -T db su - postgres -c "until pg_isready; do sleep 5; done"
create-test-db:
@docker-compose ${ARGS} exec -T db su - postgres -c "psql -c 'create database test_db;'"
devweb: db
@echo
@echo "------------------------------------------------------------------"
@echo "Running in DEVELOPMENT mode"
@echo "------------------------------------------------------------------"
@docker-compose ${ARGS} up --no-recreate --no-deps -d dev
sleep:
@echo
@echo "------------------------------------------------------------------"
@echo "Sleep for 50 seconds"
@echo "------------------------------------------------------------------"
@sleep 50
@echo "Done"
devweb-test:
@echo
@echo "------------------------------------------------------------------"
@echo "Running in DEVELOPMENT mode"
@echo "------------------------------------------------------------------"
@docker-compose exec -T dev python manage.py test --keepdb --noinput