-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
executable file
·191 lines (155 loc) · 5.45 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
# Make sure your variables are correct! (The TACC variable can be any username without ,_,-, or any other fancy characters.)
# Note that you CAN run/deploy exactly as it is, but then my deployment and yours will fight each other (we will be starting/restarting the same docker/kubernetes deployments.)
NAME=akhilsadam
TACC?=astacc
APIPORT?=5026
REDPORT?=6426
PACKAGE=compose
WORKER=compose-worker
GITHUB=git@github.com:akhilsadam/compose-dev.git
TAG=0.0.2
PYTEST=testall.py
APIFILE=doc/api.md
SEARCH=\\n
REPLACE=\n
TEST=test
PRODUCTION=production
nAPI=1
nWRK=2
iterate: kill clean build run
###############
# kubernetes: (CAN PROBABLY be simplified)
cubecp:
cp deployment/template/*.yml deployment/
cubereplT:
bash scripts/repl-deploy.sh ${TACC} 1 ${TEST} ${PRODUCTION} ${nAPI} ${nWRK}
cuberepl:
bash scripts/repl-deploy.sh ${TACC} 0 ${TEST} ${PRODUCTION} ${nAPI} ${nWRK}
cubeservicedeploy:
kubectl apply -f deployment/service-flask.yml
kubectl apply -f deployment/service-redis.yml
cubereplTdeploy:
bash scripts/repl.sh ${TEST}
cuberepldeploy:
bash scripts/repl.sh ${PRODUCTION}
cubedeploy:
kubectl apply -f deployment/data-redis-volume.yml
kubectl apply -f deployment/data-flask-volume.yml
kubectl apply -f deployment/deployment-redis.yml
kubectl apply -f deployment/deployment-worker.yml
kubectl apply -f deployment/deployment-flask.yml
kubectl apply -f deployment/service-nodeport.yml
cubecleanT:
- kubectl delete deployment compose-flask-${TEST}
- kubectl delete deployment compose-worker-${TEST}
- kubectl delete deployment compose-redis-${TEST}
- kubectl delete pvc compose-data-redis-volume-${TEST}
- kubectl delete pvc compose-data-flask-volume-${TEST}
- kubectl delete services compose-flask-service-${TEST}
- kubectl delete services compose-redis-service-${TEST}
- kubectl delete services compose-nodeport-service-${TEST}
cubeclean:
- kubectl delete deployment compose-flask-${PRODUCTION}
- kubectl delete deployment compose-worker-${PRODUCTION}
- kubectl delete deployment compose-redis-${PRODUCTION}
- kubectl delete pvc compose-data-redis-volume-${PRODUCTION}
- kubectl delete pvc compose-data-flask-volume-${PRODUCTION}
- kubectl delete services compose-flask-service-${PRODUCTION}
- kubectl delete services compose-redis-service-${PRODUCTION}
- kubectl delete services compose-nodeport-service-${PRODUCTION}
cubewipe:
- rm deployment/*.yml
cubeiterateT: cubecleanT cubecp cubereplT cubeservicedeploy cubereplTdeploy cubedeploy cubewipe cubes# Test
cubeiterate: cubeclean cubecp cuberepl cubeservicedeploy cuberepldeploy cubedeploy cubewipe cubes# Deploy
cubes:
kubectl get pods
kubectl get deployments
kubectl get pvc
###############
images:
docker images | grep ${TACC}-${PACKAGE}
docker images | grep ${TACC}-${WORKER}
ps:
docker ps -a | grep ${TACC}-${PACKAGE}
docker ps -a | grep ${TACC}-${WORKER}
kill:
- docker stop ${TACC}-data-redis
- docker stop ${TACC}-${PACKAGE}
- docker stop ${TACC}-${WORKER}
- docker stop ${TACC}-${PACKAGE}-test
clean:
- docker rm ${TACC}-data-redis
- docker rm ${TACC}-${PACKAGE}
- docker rm ${TACC}-${WORKER}
- docker rm ${TACC}-${PACKAGE}-test
- rm __pycache__/ -r
- rm app/__pycache__/ -r
- rm app/api/__pycache__/ -r
- rm app/core/__pycache__/ -r
- rm app/quarry/__pycache__/ -r
- rm app/queue/__pycache__/ -r
- rm app/shaft/__pycache__/ -r
- rm app/.pytest_cache/ -r
- rm doc/r/log_r.txt
- rm flask-data/*.mp3
- rm flask-data/*.mid
- rm redis-data/dump.rdb
build:
docker build -t ${NAME}/${PACKAGE}:${TAG} -f docker/Dockerfile.api .
docker build -t ${NAME}/${WORKER}:${TAG} -f docker/Dockerfile.wrk .
run:
# only run
sh scripts/run.sh ${NAME} ${PACKAGE} ${TAG} ${WORKER} ${TACC} ${APIPORT} ${REDPORT}
push:
docker login docker.io
docker push ${NAME}/${PACKAGE}:${TAG}
docker push ${NAME}/${WORKER}:${TAG}
# [WARNING] The following commands may require unlisted dependencies and are not part of the supported API.
# Notes for developer convenience:
# May need to be done on superuser Windows due to some R issues.
# Requires R and some packages
# Some paths will need to be modified (currently designed for @akhilsadam to run, but if you would like to do it too, please let me know).
api:
# containers must be running!
curl -X GET "http://localhost:5026/api/save" -H "accept: application/json" -o "${APIFILE}"
readme:
git status
npx @appnest/readme generate
git status
git add .
- git commit -am "[auto] update readme"
- git push
pdf:
"C:\Program Files\R\R-4.0.3\bin\Rscript" -e 'install.packages('"'pagedown'"', repos = '"'http://cran.us.r-project.org'"')' > doc/r/log_r.txt
"C:\Program Files\R\R-4.0.3\bin\Rscript" -e 'pagedown::chrome_print('"'doc/r/article.rmd'"')' > doc/r/log_r.txt
# sudo "/mnt/c/Program Files/R/R-4.0.3/bin/Rscript.exe" -e 'install.packages('"'pagedown'"')' > doc/r/log_r.txt
# "/mnt/c/Program Files/R/R-4.0.3/bin/Rscript.exe" -e 'pagedown::chrome_print('"'doc/r/article.rmd'"')' > doc/r/log_r.txt
mv doc/r/article.pdf app/static/doc/article.pdf
mv doc/r/article.html app/static/doc/article.html
commit:
git status
git add .
git commit -am "[glob] ${msg}"
git push
all:
pytest
make kill
make clean
make build
make testrun
# run doc in a win terminal
doc:
make api
make pdf
make readme
cleanport:
lsof -i:5026
mildpurge:
docker rm `docker ps -qa`
docker rmi `docker images -q`
purge:
# run on windows Powershell
- docker system prune
- net stop com.docker.service
- wsl --shutdown
"Optimize-VHD -Path C:\Users\sadam\AppData\Local\Docker\wsl\data\ext4.vhdx -Mode Full"