-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tiltfile
59 lines (49 loc) · 1.72 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
# -*- mode: Python -*-
kubectl_cmd = "kubectl"
# verify kubectl command exists
if str(local("command -v " + kubectl_cmd + " || true", quiet = True)) == "":
fail("Required command '" + kubectl_cmd + "' not found in PATH")
# Use kustomize to build the install yaml files
install = read_file('manifests/image_processor.yaml')
# Update the root security group. Tilt requires root access to update the
# running process.
objects = decode_yaml_stream(install)
for o in objects:
if o.get('kind') == 'Deployment' and o.get('metadata').get('name') == 'image-processor':
o['spec']['template']['spec']['securityContext']['runAsNonRoot'] = False
break
updated_install = encode_yaml_stream(objects)
# Apply the updated yaml to the cluster.
k8s_yaml(updated_install, allow_duplicates = True)
load('ext://restart_process', 'docker_build_with_restart')
local_resource(
'image-processor-binary',
"CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/processor ./cmd/root.go",
deps = [
"go.mod",
"go.sum",
"pkg",
"models",
"cmd",
],
)
# Build the docker image for our controller. We use a specific Dockerfile
# since tilt can't run on a scratch container.
# `only` here is important, otherwise, the container will get updated
# on _any_ file change. We only want to monitor the binary.
# If debugging is enabled, we switch to a different docker file using
# the delve port.
entrypoint = ['/processor']
dockerfile = 'tilt.dockerfile'
docker_build_with_restart(
'ghcr.io/kube-project/image-processor-service',
'.',
dockerfile = dockerfile,
entrypoint = entrypoint,
only=[
'./bin',
],
live_update = [
sync('./bin/processor', '/processor'),
],
)