tilt-dev / tilt-dev/tilt

Tilt adds Dockerfile to image if user specifies `COPY .`

Open
#3,596 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

A user had an issue copying . (in their container) into a volume: they got permission errors b/c their Dockerfile was surprise in that director, with permissions 0000.

The Dockerfile-without-permissions ended up in the container b/c of a quirk of Tilt: we add the Dockerfile to the context tar archive b/c the Docker build protocol requires that the Dockerfile exist somewhere in the archive. However, Tilt's solution is inelegant: we add the Dockerfile to the root of the context, so if the user's Dockerfile calls COPY . ..., it picks up that Dockerfile and adds it to the image, sometimes unexpectedly. What's more, we add the Dockerfile w/o specifying permissions, so the permissions zero out and we're left with a file with no permissions, causing the issue the user ran into.

#3594 fixes the latter issue -- we now tar in the Dockerfile with permissions 0644 so users can at least interact with it. The ideal solution here would be to replicate Docker's behavior of putting the Dockerfile into the context with a random name and then .dockerignoreing that name so that, while the DF is in the archive (as is needed for building the image), it doesn't get copied into the container if the user runs COPY . ....

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 in internal/build/tar.go around line 251, then compare the referenced Docker CLI context handling. Trace how Tilt adds the Dockerfile to the context archive and how Dockerfile and .dockerignore entries are represented. Done means a Docker build still receives the Dockerfile, while COPY . does not include that injected file.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, go
Domain
build-system, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.