-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
162 lines (139 loc) · 6.37 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
PROJECT_ID := minisass
export COMPOSE_FILE=docker-compose.yml:docker-compose.override.yml
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 "------------------------------------------------------------------"
@# Dont confuse this with the dbbackup make command below
@# This one runs the postgis-backup cron container
@# We add --no-recreate so that it does not destroy & recreate the db container
@docker-compose up -d
main:
@echo
@echo "------------------------------------------------------------------"
@echo "Running main services for testing"
@echo "------------------------------------------------------------------"
@docker compose up -d db minio django
test:
@echo
@echo "------------------------------------------------------------------"
@echo "Running test"
@echo "------------------------------------------------------------------"7
@docker compose exec django bash -c "python manage.py test"
dev:
@echo
@echo "------------------------------------------------------------------"
@echo "Running in dev mode"
@echo "------------------------------------------------------------------"
@docker-compose ${ARGS} --profile dev up -d
frontend-dev:
@echo
@echo "------------------------------------------------------------------"
@echo "Run frontend dev"
@echo "------------------------------------------------------------------"
@cd django_project/minisass_frontend; npm install --verbose; npm start;
build:
@echo
@echo "------------------------------------------------------------------"
@echo "Building in production mode"
@echo "------------------------------------------------------------------"
@docker-compose -p $(PROJECT_ID) build --no-cache
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 -p $(PROJECT_ID) 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 -p $(PROJECT_ID) ps
kill:
@echo
@echo "------------------------------------------------------------------"
@echo "Killing in production mode"
@echo "------------------------------------------------------------------"
@docker-compose -p $(PROJECT_ID) stop
down: kill
@echo
@echo "------------------------------------------------------------------"
@echo "Removing production instance!!! "
@echo "------------------------------------------------------------------"
@docker-compose -p $(PROJECT_ID) down
shell:
@echo
@echo "------------------------------------------------------------------"
@echo "Shelling in in production mode"
@echo "------------------------------------------------------------------"
@docker-compose -p $(PROJECT_ID) exec django /bin/bash
dev-shell:
@echo
@echo "------------------------------------------------------------------"
@echo "Shelling in in development mode"
@echo "------------------------------------------------------------------"
@docker-compose -p $(PROJECT_ID) exec dev /bin/bash
db-bash:
@echo
@echo "------------------------------------------------------------------"
@echo "Entering DB Bash in production mode"
@echo "------------------------------------------------------------------"
@docker-compose -p $(PROJECT_ID) exec db sh
db-shell:
@echo
@echo "------------------------------------------------------------------"
@echo "Entering PostgreSQL Shell in production mode"
@echo "------------------------------------------------------------------"
docker-compose -p $(PROJECT_ID) exec db su - postgres -c "psql"
collectstatic:
@echo
@echo "------------------------------------------------------------------"
@echo "Collecting static in production mode"
@echo "------------------------------------------------------------------"
#@docker-compose -p $(PROJECT_ID) 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
# --------------- 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."