Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions template/Tiltfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
# If tilt_options.json exists read it and load the default_registry value from it
# If tilt_options.json exists read it
settings = read_json('tilt_options.json', default={})
registry = settings.get('default_registry', 'oci.stackable.tech/sandbox')

# Configure default registry either read from config file above, or with default value of "oci.stackable.tech/sandbox"
default_registry(registry)

# Configure which builder to use from config file, defaults to 'nix'
builder = settings.get('builder', 'nix')

meta = read_json('nix/meta.json')
operator_name = meta['operator']['name']

custom_build(
registry + '/' + operator_name,
'make regenerate-nix && nix-build . -A docker --argstr dockerName "${EXPECTED_REGISTRY}/' + operator_name + '" && ./result/load-image | docker load',
deps=['rust', 'Cargo.toml', 'Cargo.lock', 'default.nix', "nix", 'build.rs', 'vendor'],
ignore=['*.~undo-tree~'],
# ignore=['result*', 'Cargo.nix', 'target', *.yaml],
outputs_image_ref_to='result/ref',
)
if builder == 'nix':
custom_build(
registry + '/' + operator_name,
'make regenerate-nix && nix-build . -A docker --argstr dockerName "${EXPECTED_REGISTRY}/' + operator_name + '" && ./result/load-image | docker load',
deps=['rust', 'Cargo.toml', 'Cargo.lock', 'default.nix', "nix", 'build.rs', 'vendor'],
ignore=['*.~undo-tree~'],
# ignore=['result*', 'Cargo.nix', 'target', *.yaml],
outputs_image_ref_to='result/ref',
)
else if builder == 'docker':
docker_build(registry + '/' + operator_name, '.', dockerfile='docker/Dockerfile')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this also need deps to be set, like the custom_build?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't look like docker_build supports that: https://docs.tilt.dev/api.html#api.docker_build

Not sure how it would know when to rebuild though ...

Copy link
Member Author

@soenkeliebau soenkeliebau Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The '.' in the docker_build call is the context, that is watched for changes, a rebuild is triggered when anything changes in the current working directory.
We can probably do better than that, but auto-rebuild should happen with this..

docker_build supports live update functionality, which I think would allow us to copy the compiled binary into the running container .. not sure how the restart would then happen though ...

https://github.com/tilt-dev/live_update/blob/master/go/Tiltfile

else:
fail('Unsupported builder specified: [' + builder + '] - currently supported builders are: [docker, crate2nix]')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fail('Unsupported builder specified: [' + builder + '] - currently supported builders are: [docker, crate2nix]')
fail('Unsupported builder specified: [' + builder + '] - currently supported builders are: [docker, nix]')


# Load the latest CRDs from Nix
watch_file('result')
Expand Down