forked from atticlab/wormhole
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTiltfile
148 lines (119 loc) · 4.77 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
# This Tiltfile contains the deployment and build config for the Wormhole devnet.
#
# We use Buildkit cache mounts and careful layering to avoid unnecessary rebuilds - almost
# all source code changes result in small, incremental rebuilds. Dockerfiles are written such
# that, for example, changing the contract source code won't cause Solana itself to be rebuilt.
#
# Graph of dependencies between Dockerfiles, image refs and k8s StatefulSets:
#
# Dockerfile Image ref StatefulSet
# +------------------------------------------------------------------------------+
# rust+1.45
# + +-----------------+
# +-> Dockerfile.agent +-> solana-agent +--------+-----> | [agent] |
# | | +--> | guardian-N |
# +-> solana/Dockerfile +-> solana-contract +---+ | | +-- --------------+
# | | | |
# +-> third_party/solana/Dockerfile <--------------+ | |
# + | | +-----------------+
# +--> solana-devnet +-------|-----> | solana-devnet |
# golang:1.15.3 +-----> | [setup] |
# + | +-----------------+
# +-> bridge/Dockerfile +-> guardiand-image +---------+
#
#
# node:lts-alpine
# + +-----------------+
# +-> ethereum/Dockerfile +-> eth+node +------------------> | eth|devnet |
# +-----------------+
#
config.define_string("num", False, "Number of guardian nodes to run")
cfg = config.parse()
num_guardians = int(cfg.get("num", "5"))
# protos
local_resource(
name = "proto-gen",
deps = ["./proto", "./generate-protos.sh"],
cmd = "./generate-protos.sh",
)
# bridge
docker_build(
ref = "guardiand-image",
context = "bridge",
dockerfile = "bridge/Dockerfile",
)
def build_bridge_yaml():
bridge_yaml = read_yaml_stream("devnet/bridge.yaml")
for obj in bridge_yaml:
if obj["kind"] == "StatefulSet" and obj["metadata"]["name"] == "guardian":
obj["spec"]["replicas"] = num_guardians
container = obj["spec"]["template"]["spec"]["containers"][0]
if container["name"] != "guardiand":
fail("container 0 is not guardiand")
container["command"] += ["--devNumGuardians", str(num_guardians)]
return encode_yaml_stream(bridge_yaml)
k8s_yaml(build_bridge_yaml())
k8s_resource("guardian", resource_deps = ["proto-gen"])
# solana agent and cli (runs alongside bridge)
docker_build(
ref = "solana-agent",
context = ".",
only = ["./proto", "./solana"],
dockerfile = "Dockerfile.agent",
# Ignore target folders from local (non-container) development.
ignore = ["./solana/target", "./solana/agent/target", "./solana/cli/target"],
)
# solana smart contract
docker_build(
ref = "solana-contract",
context = "solana",
dockerfile = "solana/Dockerfile",
)
# solana local devnet
docker_build(
ref = "solana-devnet",
context = "third_party/solana",
dockerfile = "third_party/solana/Dockerfile",
)
k8s_yaml("devnet/solana-devnet.yaml")
k8s_resource("solana-devnet", port_forwards=[
port_forward(8899, name="Solana RPC [:8899]"),
port_forward(8900, name="Solana WS [:8900]"),
port_forward(9000, name="Solana PubSub [:9000]"),
])
# eth devnet
docker_build(
ref = "eth-node",
context = "./ethereum",
dockerfile = "./ethereum/Dockerfile",
# ignore local node_modules (in case they're present)
ignore = ["./ethereum/node_modules"],
# sync external scripts for incremental development
# (everything else needs to be restarted from scratch for determinism)
#
# This relies on --update-mode=exec to work properly with a non-root user.
# https://github.com/tilt-dev/tilt/issues/3708
live_update = [
sync("./ethereum/src", "/home/node/app/src"),
],
)
k8s_yaml("devnet/eth-devnet.yaml")
k8s_resource("eth-devnet", port_forwards=[
port_forward(8545, name="Ganache RPC [:8545]")
])
# web frontend
docker_build(
ref = "web",
context = "./web",
dockerfile = "./web/Dockerfile",
ignore = ["./web/node_modules"],
live_update = [
sync("./web/src", "/home/node/app/src"),
sync("./web/public", "/home/node/app/public"),
sync("./web/contracts", "/home/node/app/contracts"),
],
)
k8s_yaml("devnet/web.yaml")
k8s_resource("web", port_forwards=[
port_forward(3000, name="Experimental Web UI [:3000]")
])