-
Notifications
You must be signed in to change notification settings - Fork 1
/
Taskfile.yml
201 lines (174 loc) · 6.04 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
version: '3'
dotenv:
- .env
env:
COMMIT_SHA:
sh: git rev-parse --short HEAD
vars:
PROJECT_NAME: giga-dataops_data-sharing
tasks:
default:
desc: Build and start Docker containers
cmds:
- task: config
- docker compose --project-name giga-dataops-platform --file docker-compose-network.yaml up --detach --build --remove-orphans {{.CLI_ARGS}}
- docker compose --project-name {{.PROJECT_NAME}} up --detach --build --remove-orphans {{.CLI_ARGS}}
setup:
desc: Run initial setup
cmds:
- task: setup-pre-commit
- task: setup-python
- task: setup-helm
setup-pre-commit:
internal: true
desc: Install pre-commit hooks
cmds:
- pip install -U pre-commit
- pre-commit install --install-hooks -t pre-commit -t commit-msg
setup-python:
internal: true
desc: Setup Python dependencies
cmds:
- poetry env use 3.11
- poetry install
setup-helm:
internal: true
desc: Setup Helm repositories
cmds:
- helm dependency update helm/data-sharing-proxy
config:
desc: Generate config files
sources:
- ./conf-template/*
- ./.env
generates:
- ./conf/*
cmds:
- mkdir -p conf
- >
sed -e 's|{{`{{.STORAGE_ACCESS_KEY}}`}}|{{.STORAGE_ACCESS_KEY}}|'
-e 's|{{`{{.STORAGE_ACCOUNT_NAME}}`}}|{{.STORAGE_ACCOUNT_NAME}}|'
conf-template/core-site.xml > conf/core-site.xml
- >
sed -e 's!{{`{{.DELTA_BEARER_TOKEN}}`}}!{{.DELTA_BEARER_TOKEN}}!'
-e 's!{{`{{.STORAGE_ACCOUNT_NAME}}`}}!{{.STORAGE_ACCOUNT_NAME}}!'
-e 's!{{`{{.CONTAINER_NAME}}`}}!{{.CONTAINER_NAME}}!'
-e 's!{{`{{.CONTAINER_PATH}}`}}!{{.CONTAINER_PATH}}!'
conf-template/delta-sharing-server.yaml > conf/delta-sharing-server.yaml
logs:
desc: Attach to Docker logs
cmds:
- docker compose --project-name {{.PROJECT_NAME}} logs --follow {{.CLI_ARGS}}
stop:
desc: Stop containers
cmds:
- docker compose --project-name {{.PROJECT_NAME}} stop {{.CLI_ARGS}}
restart:
desc: Restart containers
cmds:
- task: config
- docker compose --project-name {{.PROJECT_NAME}} restart {{.CLI_ARGS}}
exec:
desc: Run a command in the specified container
cmds:
- docker compose --project-name {{.PROJECT_NAME}} exec {{.CLI_ARGS}}
clean:
desc: Remove containers
cmds:
- docker compose --project-name {{.PROJECT_NAME}} down --volumes --remove-orphans {{.CLI_ARGS}}
build-and-push:
desc: Build and push Docker image
cmds:
- task: build
- task: push
build:
internal: true
desc: Build Docker image
cmds:
- docker build --network host --tag {{.DATA_SHARING_PROXY_IMAGE_REPOSITORY}}:{{.COMMIT_SHA}} -f proxy.prod.Dockerfile .
- docker build --network host --tag {{.DATA_SHARING_DELTA_IMAGE_REPOSITORY}}:{{.COMMIT_SHA}} -f delta.prod.Dockerfile .
push:
internal: true
desc: Push Docker image
cmds:
- docker push {{.DATA_SHARING_PROXY_IMAGE_REPOSITORY}}:{{.COMMIT_SHA}}
- docker push {{.DATA_SHARING_DELTA_IMAGE_REPOSITORY}}:{{.COMMIT_SHA}}
k8s-prereqs:
desc: Install K8s prerequisites
dir: infra/k8s
cmds:
- kubectl apply -f namespace.yaml
- kubectl apply -f configmap.yaml --namespace giga-data-sharing
- kubectl apply -f secrets.yaml --namespace giga-data-sharing
helm-up:
desc: Install/upgrade Helm chart on a local K8s cluster
dir: infra
cmds:
- task: k8s-prereqs
- >
helm upgrade --install data-sharing-delta ./helm/data-sharing-delta
--namespace giga-data-sharing
--set image.repository={{.DATA_SHARING_DELTA_IMAGE_REPOSITORY}}
--set image.tag={{.COMMIT_SHA}}
- >
helm upgrade --install data-sharing-proxy ./helm/data-sharing-proxy
--namespace giga-data-sharing
--set image.repository={{.DATA_SHARING_PROXY_IMAGE_REPOSITORY}}
--set image.tag={{.COMMIT_SHA}}
--set service.type=LoadBalancer
helm-upi:
desc: Install/upgrade Helm chart on a K8s cluster with configured ingress
dir: infra
cmds:
- task: k8s-prereqs
- >
helm upgrade --install data-sharing-delta ./helm/data-sharing-delta
--namespace giga-data-sharing
--set image.repository={{.DATA_SHARING_DELTA_IMAGE_REPOSITORY}}
--set image.tag={{.COMMIT_SHA}}
--set autoscaling.enabled=true
--set podDisruptionBudget.enabled=true
- >
helm upgrade --install data-sharing-proxy ./helm/data-sharing-proxy
--namespace giga-data-sharing
--set image.repository={{.DATA_SHARING_PROXY_IMAGE_REPOSITORY}}
--set image.tag={{.COMMIT_SHA}}
--set ingress.enabled=true
--set ingress.annotations=null
--set ingress.hosts[0].host={{.DATA_SHARING_INGRESS_HOST}}
--set ingress.hosts[0].paths[0].path=/
--set ingress.hosts[0].paths[0].pathType=Prefix
--set postgresql.primary.readinessProbe.enabled=false
--set postgresql.primary.livenessProbe.enabled=false
--set autoscaling.enabled=true
--set podDisruptionBudget.enabled=true
helm-down:
desc: Uninstall Helm chart
cmds:
- helm uninstall data-sharing-proxy --namespace giga-data-sharing
- helm uninstall data-sharing-delta --namespace giga-data-sharing
helm-clean:
desc: Clean K8s resources
dir: infra
cmds:
- kubectl delete -f k8s/namespace.yaml
generate-delta-config:
desc: Generate Delta Sharing config
cmds:
- task exec -- proxy python -m scripts.generate_delta_config
makemigrations:
desc: Generate database migrations
cmds:
- task exec -- proxy alembic revision --autogenerate -m "{{.CLI_ARGS}}"
migrate:
desc: Run database migrations
cmds:
- task exec -- proxy alembic upgrade head
psql:
desc: Connect to database
cmds:
- task exec -- db psql -U {{.POSTGRESQL_USERNAME}} -d {{.POSTGRESQL_DATABASE}}
load-fixtures:
desc: Install database fixtures
cmds:
- task exec -- proxy python -m scripts.load_fixtures {{.CLI_ARGS}}