-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathTiltfile
More file actions
157 lines (134 loc) · 5.47 KB
/
Copy pathTiltfile
File metadata and controls
157 lines (134 loc) · 5.47 KB
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
# -*- mode: Python -*-
# Lake local K8s development environment
#
# Prerequisites: k3d, tilt, kubectl
# Usage: ./scripts/k8s.sh up
load('ext://restart_process', 'docker_build_with_restart')
# ---------------------------------------------------------------------------
# Configuration
# ---------------------------------------------------------------------------
# Port offset — set by k8s.sh to avoid conflicts with host services.
# When offset is 0, ports match the standard dev setup (8080, 5173, etc.).
# When offset is e.g. 100, ports become 8180, 5273, etc.
PORT_OFFSET = int(os.environ.get('LAKE_PORT_OFFSET', '0'))
def p(local_port, remote_port=None):
"""Apply port offset to local port. Remote (container) port is unchanged."""
if remote_port == None:
remote_port = local_port
return '%d:%d' % (local_port + PORT_OFFSET, remote_port)
if PORT_OFFSET != 0:
print('Port offset: +%d' % PORT_OFFSET)
cluster_name = os.environ.get('LAKE_CLUSTER_NAME', 'lake-' + os.environ.get('USER', 'dev'))
allow_k8s_contexts(['k3d-' + cluster_name])
default_registry('localhost:5050')
# ---------------------------------------------------------------------------
# Infrastructure services
# ---------------------------------------------------------------------------
k8s_yaml(kustomize('k8s/base'))
k8s_resource('postgres', labels=['infra'],
port_forwards=[p(5432)])
k8s_resource('clickhouse', labels=['infra'],
port_forwards=[p(8123), p(9100, 9000)])
k8s_resource('neo4j', labels=['infra'],
port_forwards=[p(7474), p(7687)])
k8s_resource('temporal', labels=['infra'],
resource_deps=['postgres'],
port_forwards=[p(7233)])
k8s_resource('temporal-ui', labels=['infra'],
resource_deps=['temporal'],
port_forwards=[p(8233, 8080)])
# ---------------------------------------------------------------------------
# GeoIP databases — mounted from host into k3d node at /data/geoip
# by the k8s.sh setup script.
# ---------------------------------------------------------------------------
# ---------------------------------------------------------------------------
# API service
# ---------------------------------------------------------------------------
docker_build_with_restart(
'lake-api',
context='.',
dockerfile='k8s/docker/api.Dockerfile',
only=[
'go.mod', 'go.sum',
'api/', 'agent/', 'admin/',
'indexer/', 'slack/', 'utils/',
],
entrypoint=['/usr/local/bin/lake-api'],
live_update=[
sync('.', '/lake'),
run(
'CGO_ENABLED=0 go build -o /usr/local/bin/lake-api ./api/main.go',
trigger=[
'api/', 'agent/',
'go.mod', 'go.sum',
],
),
],
)
k8s_resource('api', labels=['app'],
resource_deps=['indexer', 'postgres', 'neo4j', 'temporal'],
port_forwards=[p(8080)])
# ---------------------------------------------------------------------------
# Indexer service
# ---------------------------------------------------------------------------
docker_build_with_restart(
'lake-indexer',
context='.',
dockerfile='k8s/docker/indexer.Dockerfile',
only=[
'go.mod', 'go.sum',
'indexer/', 'admin/',
'api/', 'agent/', 'slack/', 'utils/',
],
entrypoint=['/usr/local/bin/lake-indexer', '--verbose', '--migrations-enable', '--setup-remote-tables'],
live_update=[
sync('.', '/lake'),
run(
'CGO_ENABLED=0 go build -o /usr/local/bin/lake-indexer ./indexer/cmd/indexer/main.go',
trigger=[
'indexer/',
'go.mod', 'go.sum',
],
),
],
)
k8s_resource('indexer', labels=['app'],
resource_deps=['clickhouse', 'postgres'],
port_forwards=[p(3010)])
# ---------------------------------------------------------------------------
# Web frontend
# ---------------------------------------------------------------------------
docker_build(
'lake-web',
context='.',
dockerfile='k8s/docker/web-dev.Dockerfile',
only=['web/'],
live_update=[
sync('./web/src', '/app/src'),
sync('./web/public', '/app/public'),
sync('./web/index.html', '/app/index.html'),
sync('./web/vite.config.ts', '/app/vite.config.ts'),
sync('./web/tsconfig.json', '/app/tsconfig.json'),
sync('./web/tsconfig.app.json', '/app/tsconfig.app.json'),
sync('./web/tsconfig.node.json', '/app/tsconfig.node.json'),
],
)
k8s_resource('web', labels=['app'],
port_forwards=[p(5173, 5173)])
# ---------------------------------------------------------------------------
# Print port mapping on startup
# ---------------------------------------------------------------------------
if PORT_OFFSET != 0:
print('')
print('Port mapping (offset +%d):' % PORT_OFFSET)
print(' web: http://localhost:%d' % (5173 + PORT_OFFSET))
print(' api: http://localhost:%d' % (8080 + PORT_OFFSET))
print(' clickhouse: localhost:%d (HTTP), localhost:%d (TCP)' % (8123 + PORT_OFFSET, 9100 + PORT_OFFSET))
print(' postgres: localhost:%d' % (5432 + PORT_OFFSET))
print(' neo4j: localhost:%d (browser), localhost:%d (bolt)' % (7474 + PORT_OFFSET, 7687 + PORT_OFFSET))
print(' temporal-ui: http://localhost:%d' % (8233 + PORT_OFFSET))
print('')
# ---------------------------------------------------------------------------
# Tilt settings
# ---------------------------------------------------------------------------
update_settings(max_parallel_updates=3, k8s_upsert_timeout_secs=120)