-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
158 lines (129 loc) · 4.08 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
#* Variables
SHELL := /usr/bin/env bash
PYTHON := python
PYTHONPATH := `pwd`
#* Django Local
.PHONY: l-build
l-build:
docker-compose -f docker-compose-local.yml build
docker-compose -f docker-compose-local.yml run --rm django python manage.py migrate
.PHONY: l-build-start
l-build-start:
make l-flush
docker-compose -f docker-compose-local.yml build
docker-compose -f docker-compose-local.yml run --rm django python manage.py migrate
make l-superuser
docker-compose -f docker-compose-local.yml up
.PHONY: l-start
l-start:
docker-compose -f docker-compose-local.yml up
.PHONY: l-startd
l-startd:
docker-compose -f docker-compose-local.yml up -d
.PHONY: l-superuser
l-superuser:
docker-compose -f docker-compose-local.yml run --rm django python manage.py createsuperuser
.PHONY: makemigrations
l-makemigrations:
docker-compose -f docker-compose-local.yml run --rm django python manage.py makemigrations $(app)
.PHONY: l-migrations
l-migrations:
docker-compose -f docker-compose-local.yml run --rm django python manage.py makemigrations $(app)
docker-compose -f docker-compose-local.yml run --rm django python manage.py migrate
.PHONY: flush
l-flush:
docker rm -f django
docker rm -f celeryworker
docker rm -f celerybeat
docker rm -f flower
docker rm -f postgres
docker rm -f sars-dashboard_redis_1
docker rm -f mailhog
docker volume rm -f sars-dashboard_local_postgres_data
docker volume rm -f sars-dashboard_local_postgres_data_backups
docker volume rm -f sars-dashboard_local_redis
.PHONY: rmv-migrations
rmv-migrations:
find . -path "*/migrations/*.py" -not -name "__init__.py" -delete
find . -path "*/migrations/*.pyc" -delete
rm -rf sars_dashboard/media
.PHONY: app
app:
docker-compose -f docker-compose-local.yml run --rm django python manage.py startapp $(name)
#* Django Production
.PHONY: p-build
p-build:
docker-compose -f docker-compose-production.yml build
docker-compose -f docker-compose-production.yml run --rm django python manage.py migrate
.PHONY: p-start
p-start:
docker-compose -f docker-compose-production.yml up
.PHONY: p-startd
p-startd:
docker-compose -f docker-compose-production.yml up -d
.PHONY: p-superuser
p-superuser:
docker-compose -f docker-compose-production.yml run --rm django python manage.py createsuperuser
.PHONY: p-build-start
p-build-start:
make p-flush
make p-build
make p-superuser
make p-start
.PHONY: p-build-startd
p-build-startd:
make p-flush
make p-build
make p-superuser
make p-startd
.PHONY: p-shell
p-shell:
docker-compose -f docker-compose-production.yml run --rm django python manage.py shell
.PHONY: p-flush
p-flush:
docker rm -f sars-dashboard_nginx_1
docker rm -f sars-dashboard_flower_1
docker rm -f sars-dashboard_celerybeat_1
docker rm -f sars-dashboard_django_1
docker rm -f sars-dashboard_celeryworker_1
docker rm -f sars-dashboard_redis_1
docker rm -f sars-dashboard_postgres_1
docker volume rm -f sars-dashboard_production_data
docker volume rm -f sars-dashboard_production_postgres_data
docker volume rm -f sars-dashboard_production_postgres_data_backups
docker volume rm -f sars-dashboard_production_static
docker volume rm -f sars-dashboard_production_redis
#* K8
.PHONY: kompose
kompose:
eval $(minikube docker-env)
make p-build
kompose convert -f docker-compose-production.yml -o kubernetes-production.yml --build local -v --push-image=false --controller deployment
.PHONY: k-apply
k-apply:
kubectl apply -f kubernetes-production.yml
.PHONY: k-delete
k-delete:
kubectl delete -f kubernetes-production.yml
.PHONY: k-service
k-service:
minikube service nginx
.PHONY: k-service
k-service:
minikube service nginx
.PHONY: k-migrate
k-migrate:
kubectl exec -ti $$(kubectl get pods -l="io.kompose.service=django" -o jsonpath="{.items[0].metadata.name}") -- python manage.py migrate
.PHONY: k-superuser
k-superuser:
kubectl exec -ti $$(kubectl get pods -l="io.kompose.service=django" -o jsonpath="{.items[0].metadata.name}") -- python manage.py createsuperuser
.PHONY: k8
k8:
make kompose
make k-apply
make k-superuser
make k-service
.PHONY: restart-minikube
restart-minikube:
minikube delete --all --purge
minikube start