-
Notifications
You must be signed in to change notification settings - Fork 239
/
Tiltfile
155 lines (136 loc) · 4.18 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
load('ext://restart_process', 'docker_build_with_restart')
secret_settings(disable_scrub=True)
if config.tilt_subcommand == "up":
if not os.path.exists("vendor"):
local(command="go mod vendor")
local(command="cd dashboard; npm i --legacy-peer-deps")
if config.tilt_subcommand == "down":
if os.path.exists("vendor"):
local(command="rm -rf vendor")
if os.path.exists("dashboard/node_modules"):
local(command="rm -rf dashboard/node_modules")
build_args = "GOOS=linux GOARCH=arm64"
if os.getenv("PLATFORM") == "amd64":
build_args = "GOOS=linux GOARCH=amd64"
allow_k8s_contexts('kind-porter')
cluster = str(local('kubectl config current-context')).strip()
if (cluster.startswith("kind-")):
install = kustomize('zarf/helm', flags=["--enable-helm"])
decoded = decode_yaml_stream(install)
for d in decoded:
if d.get('kind') == 'Deployment':
if "securityContext" in d['spec']['template']['spec']:
d['spec']['template']['spec'].pop('securityContext')
for c in d['spec']['template']['spec']['containers']:
if "securityContext" in c:
c.pop('securityContext')
updated_install = encode_yaml_stream(decoded)
k8s_yaml(updated_install)
else:
local("echo 'Be careful that you aren't connected to a staging or prod cluster' && exit 1")
exit()
ngrok_url = os.getenv("NGROK_URL")
if ngrok_url == "":
local("echo 'NGROK_URL env variable is required but not set' && exit 1")
exit()
k8s_resource(
workload='porter-server-web',
port_forwards=["8080:8080"],
labels=["porter"],
resource_deps=["porter-binary"],
)
k8s_resource(
workload='porter-auth-web',
port_forwards=["8090:8090"],
labels=["porter"],
resource_deps=["porter-binary"],
)
watch_file('zarf/helm/.server.env')
watch_file('zarf/helm/.dashboard.env')
## Build binary locally for faster devexp
local_resource(
name='porter-binary',
cmd='''GOWORK=off CGO_ENABLED=0 %s go build -mod vendor -gcflags '-N -l' -tags ee -o ./bin/porter ./cmd/app/main.go''' % build_args,
deps=[
"api",
"build",
"ee",
"internal",
"pkg",
"vendor",
"cmd",
],
resource_deps=["postgresql"],
labels=["z_binaries"]
)
local_resource(
name="migrations-binary",
cmd='''GOWORK=off CGO_ENABLED=0 %s go build -mod vendor -gcflags '-N -l' -tags ee -o ./bin/migrate ./cmd/migrate/main.go ./cmd/migrate/migrate_ee.go''' % build_args,
resource_deps=["postgresql"],
labels=["z_binaries"],
)
local_resource(
name="disable-porter-helm-test",
cmd='tilt disable porter-server-web-test-connection',
resource_deps=["porter-server-web"]
)
local_resource(
name="disable-auth-helm-test",
cmd='tilt disable porter-auth-web-test-connection',
resource_deps=["porter-auth-web"]
)
docker_build_with_restart(
ref="porter1/porter-server",
context=".",
dockerfile="zarf/docker/Dockerfile.server.tilt",
entrypoint='/app/migrate && /app/porter',
build_args={},
only=[
"bin",
],
live_update=[
sync('./bin/porter', '/app/'),
sync('./bin/migrate', '/app/'),
]
)
docker_build_with_restart(
ref="porter1/porter-auth",
context=".",
dockerfile="zarf/docker/Dockerfile.server.tilt",
entrypoint='/app/porter --auth',
build_args={},
only=[
"bin",
],
live_update=[
sync('./bin/porter', '/app/'),
]
)
local_resource(
name='reload-server-config',
cmd='kubectl rollout restart deployment porter-server-web',
deps=[
"zarf/helm/.server.env"
],
labels=["porter"],
resource_deps=["porter-server-web"]
)
# Frontend
local_resource(
name="porter-dashboard",
serve_cmd="npm start",
serve_dir="dashboard",
serve_env={
"ENV_FILE": "../zarf/helm/.dashboard.env",
"NODE_OPTIONS":"--openssl-legacy-provider"
},
deps=[
"dashboard/package.json",
],
resource_deps=["postgresql"],
labels=["porter"]
)
local_resource('public-url',
serve_cmd='''
echo " \n\n****** NGROK URL ****** \n\n" && echo https://%s && echo "\n\n********\n\n" && ngrok http 8081 --log=stdout --domain=%s'''
% (ngrok_url, ngrok_url), resource_deps=["porter-dashboard"], labels=["porter"])