Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker_build only param is counterintuitive #5897

Open
tylermichael opened this issue Jul 20, 2022 · 3 comments
Open

docker_build only param is counterintuitive #5897

tylermichael opened this issue Jul 20, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@tylermichael
Copy link

Expected Behavior

It feels counterintuitive the way the only parameter for docker_build behaves. I want it to only change what files Tilt considers for a rebuild, not change what folders are added to my docker build context.

Because Tilt uses this one parameter to do two different things, it's cumbersome to do something that seemingly should be trivial.

I think either this parameters behavior should be changed or a new parameter be introduced.

Current Behavior

This parameter limits what files and folders are sent to the context AND tells Tilt what files to watch.

It does seem to operate how it's documented, though. 😃

I suppose I could list out every folder I want to ignore with the ignore param but that feels much too cumbersome.

Steps to Reproduce

In this contrived example, I only want to rebuild if a change happens in the frontend folder, while also including an assets directory in my build. Because the context I pass to docker_build is broad, any change in my monorepo causes a rebuild. Using the only parameter seems like an obvious solution, but it will also change the build context, which I don't want to happen.

My file tree looks similar to:

api/
  /src/
    server.ts
  ... other stuff
frontend/
  Tiltfile
  Dockerfile
  /src/
    index.ts
... lots of other folders
assets/
  a_resource.json

My docker_build looks like:

docker_build(
    'frontend',
    '..', # the root of a monorepo
    dockerfile='frontend/Dockerfile',
    only=['frontend']
)

And the Dockerfile is similar to:

FROM node:latest
COPY frontend /frontend
COPY assets/ assets/
...

This build will fail with an error message like this because only the frontend folder is sent to the docker build.

Build Failed: ImageBuild: "/assets" not found

About Your Use Case

I want a way to tell Tilt, only consider changes to these files or this path for a rebuild, but don't exclude everything else from the build.

@tylermichael tylermichael added the bug Something isn't working label Jul 20, 2022
@nicks nicks added enhancement New feature or request and removed bug Something isn't working labels Jul 20, 2022
@nicks
Copy link
Member

nicks commented Jul 20, 2022

We currently have two APIs for this:

both of which will tell tilt not to rebuild anything when certain files change

i don't think we're opposed in theory to having a docker_build api for this. But in practice, there are already a lot of ways to configure filewatches. When adding a new way, we have to be careful how it interacts with all existing mechanisms. Getting filewatch APIs right is very tricky.

@tylermichael
Copy link
Author

Agreed, it's a tricky thing to get right.

I have other resources defined that have different (and conflicting) requirements so those two APIs are too broad for what I need.

Ideally, I could define more finely grained watch options like I'm describing on a per resource basis.

@stuarthendren
Copy link

stuarthendren commented Oct 27, 2022

I came across this issue, when I first reached for only to reduce some un needed builds to find it doesn't work as I would have expected. I expected the context parameter and my .dockerignore file to be in control of the context and the only/ignore to be in control of the watch settings. (This doesn't mean I'm right, it's just what I expected it to do.)

I hit this problem when the build images uses turbo prune. So I wanted to limit the watch settings, per docker_build but not the context. I don't think the proposed alternatives (.tiltignore and watch_settings) allow this as they are global, not per docker_build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants