-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTiltfile
310 lines (282 loc) · 7.5 KB
/
Tiltfile
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
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
load('ext://helm_resource', 'helm_resource', 'helm_repo')
load('ext://namespace', 'namespace_create', 'namespace_inject')
update_settings(
k8s_upsert_timeout_secs = 300,
)
print("Working on context: ", k8s_context())
k8s_yaml('local-env/namespace.yaml')
helm_repo('ingress-nginx-repo', 'https://kubernetes.github.io/ingress-nginx')
helm_resource('ingress-nginx', 'ingress-nginx-repo/ingress-nginx', namespace='ingress-nginx', flags=[
'--create-namespace'
])
nginx_patch = read_file('./local-env/nginx-patch.yaml')
local_resource('nginx_patch',
'kubectl patch \
--context %s \
--namespace ingress-nginx \
svc ingress-nginx-controller \
--patch "%s"' % (k8s_context(), nginx_patch),
resource_deps=[])
k8s_yaml('local-env/ingress.yaml')
helm_repo('cockroachdb-repo', 'https://charts.cockroachdb.com/')
helm_resource('cockroachdb', 'cockroachdb-repo/cockroachdb', namespace='emeris', flags=[
"--version", "7.0.0",
"--set", "tls.enabled=false",
"--set", "config.single-node=true",
"--set", "statefulset.replicas=1",
])
k8s_resource('cockroachdb', port_forwards=[
port_forward(26257, 26257),
port_forward(65001, 8080, name='cockroachdb admin ui'),
])
helm_repo('bitnami', 'https://charts.bitnami.com/bitnami')
helm_resource('redis', 'bitnami/redis', namespace='emeris', flags=[
"--set", "auth.enabled=false",
"--set", "auth.sentinel=false",
"--set", "architecture=standalone",
])
# starport-operator
namespace_create(
'starport-system',
allow_duplicates=True,
)
k8s_yaml(helm(
'../starport-operator/helm/starport-operator',
name='starport-operator',
namespace='starport-system',
set=[
'webHooksEnabled=false',
'workerCount=5',
]
))
GITHUB_TOKEN = os.getenv("GITHUB_TOKEN")
if not GITHUB_TOKEN:
fail("⚠️ you should export GITHUB_TOKEN with a valid GitHub token (with at least repository access) to build images.")
k8s_kind('NodeSet', image_json_path='{.spec.config.nodes.traceStoreContainer.image}')
k8s_kind('Relayer')
# tracelistener images
docker_build(
'emeris/tracelistener-v42',
'../tracelistener',
build_args={'GIT_TOKEN': GITHUB_TOKEN, 'SDK_TARGET': 'v42'},
)
docker_build(
'emeris/tracelistener-v44',
'../tracelistener',
build_args={'GIT_TOKEN': GITHUB_TOKEN, 'SDK_TARGET': 'v44'},
)
# chains
k8s_yaml('local-env/nodes/cosmos-hub.yaml')
k8s_yaml('local-env/nodes/akash.yaml')
k8s_yaml('local-env/relayer.yaml')
# our services
# CNS
docker_build(
'emeris/cns-server',
'../emeris-cns-server',
build_args={'GIT_TOKEN': GITHUB_TOKEN},
)
k8s_yaml(helm(
'../emeris-cns-server/helm',
name='cns-server',
namespace='emeris',
set=[
'imagePullPolicy=Never',
'redirectURL=http://localhost:3000/login',
'test=true',
'resources=null',
]
))
def add_cns_chain(chain_name):
local_resource(
'cns-add-chain-%s' % chain_name,
'curl -f -X POST -d @./ci/dev/chains/%s.json http://localhost:8000/v1/cns/add' % chain_name,
deps=['ingress-nginx', 'cns-server'],
)
add_cns_chain('cosmos-hub')
add_cns_chain('akash')
# API SERVER
docker_build(
'emeris/api-server',
'../demeris-api-server',
build_args={'GIT_TOKEN': GITHUB_TOKEN},
)
k8s_yaml(helm(
'../demeris-api-server/helm',
name='api-server',
namespace='emeris',
set=[
'replicas=1',
'imagePullPolicy=Never',
'serviceMonitorEnabled=false', # TODO make it parametric
'resources=null',
]
))
# RPC WATCHER
docker_build(
'emeris/rpcwatcher',
'../emeris-rpcwatcher',
build_args={'GIT_TOKEN': GITHUB_TOKEN},
)
k8s_yaml(helm(
'../emeris-rpcwatcher/helm',
name='rpcwatcher',
namespace='emeris',
set=[
'imagePullPolicy=Never',
'resources=null',
]
))
# DEXINFO
docker_build(
'emeris/dexinfo',
'../emeris-dexinfo',
)
k8s_yaml(helm(
'../emeris-dexinfo/helm',
name='dexinfo',
namespace='emeris',
set=[
'image=emeris/dexinfo:latest',
'imagePullPolicy=Never',
'resources=null',
]
))
# DAGGREGATION
docker_build(
'emeris/daggregation',
'../daggregation',
)
k8s_yaml(helm(
'../daggregation/helm',
name='daggregation',
namespace='emeris',
set=[
'imagePullPolicy=Never',
'resources=null',
'dexInfoSwapsUrl=http://dexinfo:8080/swaps',
'dexInfoVerifiedDenoms=http://api-server:8000/verified_denoms',
]
))
# TICKET WATCHER
docker_build(
'emeris/ticket-watcher',
'../emeris-ticket-watcher',
build_args={'GIT_TOKEN': GITHUB_TOKEN},
)
k8s_yaml(helm(
'../emeris-ticket-watcher/helm',
name='ticket-watcher',
namespace='emeris',
set=[
'imagePullPolicy=Never',
'resources=null',
]
))
# PRICE ORACLE
FIXER_KEY = os.getenv("FIXER_KEY")
if not FIXER_KEY:
print("⚠️ Set FIXER_KEY env variable for enabling price-oracle")
else:
docker_build(
'emeris/price-oracle-server',
'../emeris-price-oracle',
build_args={'GIT_TOKEN': GITHUB_TOKEN},
)
k8s_yaml(helm(
'../emeris-price-oracle/helm',
name='price-oracle',
namespace='emeris',
set=[
'replicas=1',
'fixerKey=%s' % FIXER_KEY,
'imagePullPolicy=Never',
'resources=null',
]
))
# SDK-SERVICE-v42
docker_build(
'emeris/sdk-service-42',
'../sdk-service',
build_args={
'GIT_TOKEN': GITHUB_TOKEN,
'SDK_TARGET': 'v42',
},
)
k8s_yaml(helm(
'../sdk-service/helm',
name='sdk-service-v42',
namespace='emeris',
set=[
'replicas=1',
'image=emeris/sdk-service-42',
'resources=null',
]
))
# SDK-SERVICE-v44
docker_build(
'emeris/sdk-service-44',
'../sdk-service',
build_args={
'GIT_TOKEN': GITHUB_TOKEN,
'SDK_TARGET': 'v44',
},
)
k8s_yaml(helm(
'../sdk-service/helm',
name='sdk-service-v44',
namespace='emeris',
set=[
'replicas=1',
'image=emeris/sdk-service-44',
'resources=null',
]
))
# FRONTEND
# TODO: move Dockerfile and k8s pod yaml to separate files
# NOTE(tb): we can't use docker_build tilt instruction for the front because
# it implicitely discards the .git folder from the docker context, and vite
# needs it for the front build. The workaround is to replace docker_build with
# custom_build, but first we need to create the front Dockerfile.
local("""echo 'FROM node:16
WORKDIR /app
COPY . /app
RUN --mount=type=cache,target=/root/.npm npm ci
CMD ["npm", "run", "dev", "--", "--host", "localhost"]' > /tmp/Dockerfile.front
"""
)
custom_build(
'emeris/frontend',
# TODO(tb) A bug in Docker Buildkit forbids us to use `-f /tmp/Dockerfile.front`
# so we use an alternative.
# See https://github.com/docker/cli/issues/2249
'docker build -t $EXPECTED_REF -f - ../demeris < /tmp/Dockerfile.front',
['../demeris'],
live_update=[
sync('../demeris/src/', '/app/src/'),
]
)
k8s_yaml(blob("""
apiVersion: v1
kind: Pod
metadata:
name: frontend
namespace: emeris
spec:
containers:
- name: app
image: emeris/frontend
env:
- name: VUE_APP_GIT_VERSION
value: development
- name: VITE_FEATURE_USE_DEV
value: "true"
- name: VITE_EMERIS_DEV_ENDPOINT
value: http://localhost:8000/v1
- name: VITE_EMERIS_DEV_LIQUIDITY_ENDPOINT
value: http://localhost:8000/v1/liquidity
- name: VITE_EMERIS_DEV_WEBSOCKET_ENDPOINT
value: ws://localhost:8000/v1
"""))
k8s_resource('frontend', port_forwards=[8080])
# vim: set syntax=python: