tilt-dev / tilt-dev/tilt

docker_build only param is counterintuitive

Open
#5,897 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Go
Stars
10.1k
Forks
413
Avg merge
1d 10h
Merged PRs (30d)
6

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the docker_build entry point and trace how the only parameter affects both Docker build context contents and file watching. Use the provided monorepo example to verify that assets remain available to the Dockerfile while changes outside frontend do not trigger rebuilds; the issue does not name a specific test or source file.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker
Domain
build-system, devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.