-
Notifications
You must be signed in to change notification settings - Fork 27
/
Taskfile.yml
279 lines (235 loc) · 8.59 KB
/
Taskfile.yml
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
version: '3'
tasks:
gitcfg:
desc: Configure git
cmds:
- git config core.hooksPath .githooks
create-network:
desc: Create the external network
cmds:
- (docker network create external-net) || true
init-backend:
desc: Initialize the backend project
dir: tdrs-backend
cmds:
- task: create-network
- docker compose -f docker-compose.yml up -d --build
- docker compose -f docker-compose.yml exec web sh -c "python ./manage.py makemigrations"
- docker compose -f docker-compose.yml exec web sh -c "python ./manage.py migrate"
- docker compose -f docker-compose.yml down
- task: sentry-down
clone-sentry-repo:
desc: Clone the sentry repo
dir: sentry
cmds:
- git clone https://github.com/getsentry/self-hosted.git || true
create-sentry:
desc: Create Sentry service
dir: sentry
cmds:
# limiting the memory to 2GB and CPU to only one cpu @0, for faster response, you can remove the limittask : --cpuset-cpus 0
- (docker run --privileged -p 9001:9000 -d --memory="8g" --memory-swap="8g" --name sentry docker:dind) || true
- docker exec sentry sh -c "git clone https://github.com/getsentry/self-hosted.git || true"
# need sleep 10 for docker to start
# there is a bug with other version of self-hosted. looks like they are trying to upgrade to Django 5.0 (July 2024)
- docker exec sentry sh -c "cd self-hosted && sleep 10 && git checkout tags/23.10.1"
# add bash
- docker exec sentry sh -c "apk add bash"
- docker cp docker-compose.yml sentry:/self-hosted/docker-compose.yml
- docker cp .env sentry:/self-hosted/.env
- docker exec sentry bash -c "cd self-hosted && ./install.sh --skip-user-creation --no-report-self-hosted-issues"
# create a new user
- docker exec sentry bash -c "cd self-hosted && docker compose run --rm web createuser --email [email protected] --password admin --superuser"
# copy backup.json file to sentry
- docker cp backup.json sentry:/self-hosted/sentry/backup.json
# restore backup
- docker exec sentry bash -c "cd self-hosted && docker compose up -d"
- docker exec sentry bash -c "docker cp /self-hosted/sentry/backup.json sentry-self-hosted-web-1:/home/sentry/backup.json"
- docker exec sentry bash -c "docker exec sentry-self-hosted-web-1 bash -c 'sentry import /home/sentry/backup.json'"
- docker exec sentry bash -c "cd self-hosted && docker compose down"
- docker exec sentry bash -c "cd self-hosted && docker compose up -d"
sentry-up:
desc: Start sentry service
dir: sentry
cmds:
- docker exec sentry bash -c "cd self-hosted && docker compose up -d"
sentry-down:
desc: Stop sentry service
dir: sentry
cmds:
- docker exec sentry bash -c "cd self-hosted && docker compose down"
drop-db:
desc: Drop the backend database
dir: tdrs-backend
cmds:
- docker compose -f docker-compose.yml down
- docker volume rm tdrs-backend_postgres_data
backend-up:
desc: Start backend web server
dir: tdrs-backend
cmds:
- docker compose -f docker-compose.yml up -d
backend-down:
desc: Stop backend web server
dir: tdrs-backend
cmds:
- docker compose -f docker-compose.yml down
backend-logs:
desc: Show and follow backend web server logs
dir: tdrs-backend
cmds:
- docker compose -f docker-compose.yml logs -f
backend-restart:
desc: Restart backend web server
dir: tdrs-backend
cmds:
- docker compose -f docker-compose.yml restart
backend-bash:
desc: Open a shell in the backend container
dir: tdrs-backend
cmds:
- docker compose -f docker-compose.yml exec web sh
backend-shell:
desc: Open a Django shell in the backend container
dir: tdrs-backend
cmds:
- docker compose -f docker-compose.yml exec web sh -c "python ./manage.py shell"
backend-exec:
desc: Execute a command in the backend container
dir: tdrs-backend
vars:
CMD: '{{.CMD}}'
cmds:
- docker compose -f docker-compose.yml exec web sh -c "python manage.py {{.CMD}}"
backend-exec-seed-db:
desc: Execute seed_db command in the backend container
dir: tdrs-backend
vars:
CMD: '{{.CMD}}'
cmds:
- docker compose -f docker-compose.yml up -d
- docker compose -f docker-compose.yml exec web sh -c "python manage.py populate_stts; python ./manage.py seed_db"
backend-pytest:
desc: 'Run pytest in the backend container E.g: task backend-pytest PYTEST_ARGS="tdpservice/test/ -s -vv"'
dir: tdrs-backend
vars:
PYTEST_ARGS: '{{.PYTEST_ARGS | default "."}}'
cmds:
- task backend-up
- docker compose -f docker-compose.yml exec web sh -c "pytest {{.PYTEST_ARGS}}"
backend-remove-volumes:
desc: Remove the backend volumes
dir: tdrs-backend
cmds:
- docker compose -f docker-compose.yml down -v
backend-lint:
desc: Run flake8 in the backend container
dir: tdrs-backend
cmds:
- task backend-up
- docker compose -f docker-compose.yml exec -T web sh -c "flake8 . && if [ $? -eq 0 ]; then echo 'Flake8 linter found no issues'; fi"
backend-pip-lock:
#TODO: Add a task to lock the pip dependencies
desc: Lock the pip dependencies
dir: tdrs-backend
cmds:
- task: backend-up
- docker compose -f docker-compose.yml exec web sh -c "pipenv lock"
psql:
desc: Open a psql shell in the backend container
dir: tdrs-backend
cmds:
- task create-network || true
- docker compose -f docker-compose.yml up -d postgres
- sleep 5
- docker compose -f docker-compose.yml exec postgres sh -c "psql -U tdpuser -d tdrs_test"
clean:
desc: Remove all containers, networks, and volumes
cmds:
- docker stop $(docker ps -aq) || true
- docker rm $(docker ps -aq) || true
- docker rmi $(docker images -q) || true
- docker volume rm $(docker volume ls -q) || true
clamav-up:
desc: Start clamav service
dir: tdrs-backend
cmds:
- docker compose -f docker-compose.yml up -d clamav-rest
frontend-up:
desc: Start frontend web server
dir: tdrs-frontend
cmds:
- docker compose -f docker-compose.yml up -d
frontend-down:
desc: Stop frontend web server
dir: tdrs-frontend
cmds:
- docker compose -f docker-compose.yml down
frontend-restart:
desc: Restart frontend web server
dir: tdrs-frontend
cmds:
- docker compose -f docker-compose.yml restart
frontend-av:
desc: Start frontend with optional clamav service
dir: tdrs-frontend
cmds:
- task: frontend-up
- task: clamav-up
# need more work
frontend-init:
desc: Initialize the frontend project
dir: tdrs-frontend
cmds:
- docker compose -f docker-compose.yml up -d --build
- docker compose -f docker-compose.yml exec tdp-frontend sh -c "apk add nodejs npm"
- docker compose -f docker-compose.yml exec tdp-frontend sh -c "npm install"
- docker compose -f docker-compose.yml down
frontend-test:
desc: Run frontend tests
dir: tdrs-frontend
cmds:
- docker compose -f docker-compose.local.yml up tdp-frontend-test -d
- docker compose -f docker-compose.local.yml exec tdp-frontend-test sh -c "npm run test"
frontend-test-cov:
desc: Run frontend tests with coverage
dir: tdrs-frontend
cmds:
- docker compose -f docker-compose.local.yml up tdp-frontend-test -d
- docker compose -f docker-compose.local.yml exec tdp-frontend-test sh -c "npm run test:cov"
cypress:
desc: Run cypress tests
dir: tdrs-frontend
cmds:
- docker-compose -f docker-compose.local.yml up --build tdp-frontend-test -d
- npm run test:e2e
frontend-lint:
desc: Run eslint in the frontend container
dir: tdrs-frontend
cmds:
- docker compose -f docker-compose.local.yml up -d tdp-frontend-test --quiet-pull
- docker compose -f docker-compose.yml exec -T tdp-frontend-test sh -c "npm run lint"
frontend-logs:
desc: Show and follow frontend web server logs
dir: tdrs-frontend
cmds:
- docker compose -f docker-compose.yml logs -f
frontend-bash:
desc: Open a shell in the frontend container
dir: tdrs-frontend
cmds:
- docker compose -f docker-compose.yml exec tdp-frontend bash
up:
desc: Start both frontend and backend web servers
cmds:
- task: backend-up
- task: frontend-up
down:
desc: Stop both frontend and backend web servers
cmds:
- task: backend-down
- task: frontend-down
help:
desc: Show this help message
cmds:
- task --list