Hi there,
I've got a use case where I compile a jar via Maven, extract it from the container, then run a DockerBuild in the directory I exported. The behavior, however, is confusing me.
The code looks a bit like this
src := daggerClient.Host().Directory("./some-mvn-subproject")
mvnCache := daggerClient.CacheVolume("some cache value")
daggerClient.Container().From(imageString).
WithWorkdir("workspace").WithDirectory(".", src).
WithMountedCache("/var/.m2/repository", mvnCache).
WithExec([]string{"mvn", "package"})
_, err := mvnImage.Directory(".").Export(context.Background(), "./some-mvn-subproject")
at this point, great. I have the jar in the some-mvn-subproject/target directory as expected. I'm going to build a Dockerfile now that does something like
COPY target/my-jar.jar target/
but when running
buildContainer := daggerClient.Host().Directory("./some-mvn-subproject").DockerBuild()
(assuming there is a Dockerfile at some-mvn-subproject/Dockerfile). The issue is I get
failed to calculate checksum of ref <...>::<...>: "/target/my-jar.jar": not found
I originally thought I had just pointed to incorrect directories, but interestingly, if I immediately re-run, it works. In other words, if the jar exists at that location at the start of execution, it works. It's almost as if the dagger client is using a snapshot of the host directory from before the jar was exported (which I don't think is true).
Does this look familiar to anyone or am I perhaps misunderstanding the functionality here? Perhaps I'm just using context incorrectly?