tilt: ERROR: ImageBuild: COPY failed

Hi guys,

I have updated Tilt to the latest version (0.9.7) today and since then I’m experiencing this type of errors for all my docker images :

ERROR: ImageBuild: COPY failed: stat /var/lib/docker/tmp/docker-builder817293152/build/libs/app-1.0-SNAPSHOT.jar: no such file or directory

DockerFile looks like this :

FROM adoptopenjdk/openjdk11:jdk-11.0.2.9-slim

COPY ./build/libs/app-1.0-SNAPSHOT.jar /app.jar

CMD ["java", "-jar", "-XX:-OmitStackTraceInFastThrow", "/app.jar"]

It is my understand it’s bad practice to have relative paths in DockerFile, I’ve tried using an absolute path but the same issue occurred.

I have downgraded Tilt to version 0.9.4 and it works again. As a work around, I have configured brew to not auto update tilt but as you can imagine I would prefer to stay up to date with upgrades.

DOCKER_BUILDKIT=0 docker build -t x . and DOCKER_BUILDKIT=1 docker build -t x . both work locally.

I’m running on MacOs Mojave 10.14.6. here is the tilt doctor :

System: darwin-amd64
---
Docker
- Host: tcp://192.168.64.2:2376
- Version: 1.39
- Builder: 1
---
Kubernetes
- Env: minikube
- Context: minikube
- Cluster Name: minikube
- Namespace: default
- Container Runtime: docker
- Version: v1.15.0
---
Thanks for seeing the Tilt Doctor!
Please send this info along when filing bug reports. 💗

Thanks !

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 15 (12 by maintainers)

Commits related to this issue

Most upvoted comments

Short answer: @kalistace : you can work around this by changing the docker_build call to only='build/libs'

Long answer: Tilt does not currently support * globs in only=.... That’s because Tilt implements only='foo' as a dockerignore with the contents:

**
!foo

If you have only='**/build/libs', Tilt creates a dockerignore like:

**
!**/build/libs

Unfortunately, Docker doesn’t support this (https://github.com/moby/moby/issues/30018). If you’d like to try it out yourself, there’s a repro case in this temporary repo: https://github.com/nicks/tilt-issue1982.

This broke because we were updating Tilt’s dockerignore implementation to be more consistent with Docker’s dockerignore implementation. For a bunch of reasons, it’s super difficult to implement exclude-globs in a performant way (which is why I suspect this hasn’t been fixed in Docker core)

There are a couple possible ways we could move forward here. Maybe we could fix this, and find a performant way to implement it. Alternatively, Tilt should error if you try to use globs in only= parameters.

I could see arguments for or against being consistent with Docker, even when it means replicating their bugs. @jazzdan what do you think?

thanks! I think I have a repro case. It has something to do with the only=

I don’t have one ah ! 😃

I think I have narrowed it down a little bit more, it seems related to the only parameter from the docker_build function.

I have removed it for try-and-error debug and it worked.

Here is a snippet from my Tiltfile to illustrate my point :

Ends up with the error:

[docker_build(service, path_to(service), only='**/build/libs/*.jar') for service in services]

Doesn’t end up with an error, but also if not fit for my purpose:

[docker_build(service, path_to(service)) for service in services]

If you’re curious as to why I want this behaviour: Allows me to only rebuild manually when I want it, that is when I’m happy with my code change, I run gradle clean install, it builds my jar and deploys it to my local k8s.

Hope that helps.

I am not trying to copy from openjdk11, the jar I’m copying is relative to the Dockerfile on my filesystem. It’s packaged via Gradle.

whoops, I feel silly.