Skip to content

Commit 3e567ea

Browse files
authored
Merge pull request #545 from devigned/faster-tilt
chore: speed up tilt start and rebuild by a lot
2 parents ce5074a + 50c3211 commit 3e567ea

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

Tiltfile

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,22 @@ def validate_auth():
9696
if missing:
9797
fail("missing kustomize_substitutions keys {} in tilt-setting.json".format(missing))
9898

99+
tilt_helper_dockerfile_header = """
100+
# Tilt image
101+
FROM golang:1.13.8 as tilt-helper
102+
# Support live reloading with Tilt
103+
RUN wget --output-document /restart.sh --quiet https://raw.githubusercontent.com/windmilleng/rerun-process-wrapper/master/restart.sh && \
104+
wget --output-document /start.sh --quiet https://raw.githubusercontent.com/windmilleng/rerun-process-wrapper/master/start.sh && \
105+
chmod +x /start.sh && chmod +x /restart.sh
106+
"""
107+
108+
tilt_dockerfile_header = """
109+
FROM gcr.io/distroless/base:debug as tilt
110+
WORKDIR /
111+
COPY --from=tilt-helper /start.sh .
112+
COPY --from=tilt-helper /restart.sh .
113+
COPY manager .
114+
"""
99115

100116
# Build CAPZ and add feature gates
101117
def capz():
@@ -113,8 +129,34 @@ def capz():
113129
yaml = str(encode_yaml_stream(yaml_dict))
114130
yaml = fixup_yaml_empty_arrays(yaml)
115131

132+
# Set up a local_resource build of the provider's manager binary.
133+
local_resource(
134+
"manager",
135+
cmd = 'mkdir -p .tiltbuild;CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags \'-extldflags "-static"\' -o .tiltbuild/manager',
136+
deps = ["./api", "./main.go", "./pkg", "./controllers", "./cloud", "./exp"]
137+
)
138+
139+
dockerfile_contents = "\n".join([
140+
tilt_helper_dockerfile_header,
141+
tilt_dockerfile_header,
142+
])
143+
144+
# Set up an image build for the provider. The live update configuration syncs the output from the local_resource
145+
# build into the container.
146+
docker_build(
147+
ref = "gcr.io/k8s-staging-cluster-api-azure/cluster-api-azure-controller",
148+
context = "./.tiltbuild/",
149+
dockerfile_contents = dockerfile_contents,
150+
target = "tilt",
151+
entrypoint = ["sh", "/start.sh", "/manager"],
152+
only = "manager",
153+
live_update = [
154+
sync("./.tiltbuild/manager", "/manager"),
155+
run("sh /restart.sh"),
156+
],
157+
)
158+
116159
k8s_yaml(blob(yaml))
117-
docker_build( "gcr.io/k8s-staging-cluster-api-azure/cluster-api-azure-controller", ".")
118160

119161
##############################
120162
# Actual work happens here

0 commit comments

Comments
 (0)