forked from colfax23/poap-fun
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
143 lines (100 loc) · 2.94 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
WEB=`docker-compose ps | grep gunicorn | cut -d\ -f 1 | head -n 1`
WEBS=`docker-compose ps | grep gunicorn | cut -d\ -f 1 `
COMPOSE_ENV=override
BACKUPS_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))/backups/)
ENV_STAGE = ``
#########
#ACTIONS#
#########
build:
docker-compose -f docker-compose.yml -f docker-compose.$(COMPOSE_ENV).yml build
up:
docker-compose -f docker-compose.yml -f docker-compose.$(COMPOSE_ENV).yml up -d
start:
docker-compose -f docker-compose.yml -f docker-compose.$(COMPOSE_ENV).yml start
stop:
docker-compose -f docker-compose.yml -f docker-compose.$(COMPOSE_ENV).yml stop
ps:
docker-compose -f docker-compose.yml -f docker-compose.$(COMPOSE_ENV).yml ps
@echo "---------------------------"
@echo "Web: `ps aux | grep /usr/local/bin/gunicorn | grep -v grep | wc -l` threads running"
clean: stop
docker-compose rm -f
restart: clean build up ps
@echo "Restarted all containers"
########
#SHELLS#
########
shell-nginx:
docker exec -ti poap-fun-nginx bash
shell-web:
docker exec -ti $(WEB) bash
shell-celeryw:
docker exec -ti poap-fun-celeryworker bash
shell-celeryb:
docker exec -ti poap-fun-celerybeat bash
######
#LOGS#
######
log-nginx:
docker-compose logs nginx
log-web:
docker-compose logs web
log-web-live:
docker logs --tail 50 --follow --timestamps $(WEB)
log-celeryw:
docker-compose logs celeryworker
log-celeryb:
docker-compose logs celerybeat
log-celeryw-live:
docker-compose logs --tail 50 --follow --timestamps celeryworker
log-celeryb-live:
docker-compose logs --tail 50 --follow --timestamps celerybeat
#######
#Tests#
#######
pdb:
@echo "PDB (Exit: CONTROL + P + CONTROL + Q)"
docker attach $(WEB)
pylint:
@echo "Running Pylint"
docker exec $(WEB) /bin/sh -c "pylint *"
py-tests:
@echo "Running python tests"
docker exec $(WEB) /bin/sh -c "coverage run --source='.' manage.py test"
test-all:
@echo "Running all tests"
@echo "Running all tests in backend"
docker exec $(WEB) /bin/sh -c "coverage run --source='.' manage.py test"
docker exec $(WEB) /bin/sh -c "pylint *"
docker exec $(WEB) /bin/sh -c "coverage report -m"
coverage:
docker exec $(WEB) /bin/sh -c "coverage report -m"
############
#DJANGO OPS#
############
collectstatic:
@echo $(shell for container in $(WEBS); do\
docker exec $$container /bin/sh -c "python manage.py collectstatic --noinput" ;\
done)
migrate:
docker exec $(WEB) /bin/sh -c "python manage.py migrate"
makemigrations:
docker exec $(WEB) /bin/sh -c "python manage.py makemigrations"
clear-cache:
docker exec $(WEB) /bin/sh -c "python manage.py invalidate all"
set-django: collectstatic migrate clear-cache
@echo "Django environment setup complete."
#########
#BACKUPS#
#########
azure-backup:
docker exec $(WEB) /bin/sh -c "python manage.py azure_backup_process"
daily-backup-process: azure-backup
############
#DEPLOYMENT#
############
clean-nginx-conf:
rm -f nginx/sites-enabled/nginx.conf
deploy:clean-nginx-conf
make clean build up set-django