Error during image build when Dockerfile in subdirectory of build context
Hello!
I try to build docker image with your library and think I found a bug.
I have such project structure:
/path/to/project/docker/Dockerfile
/path/to/project/target/app.jar
In my Dockerfile:
(...)
COPY target/app.jar /opt/app/app.jar
(...)
I try to build image with code:
final String baseDirectory = "/path/to/project"; final String dockerfile = baseDirectory + "/docker/Dockerfile"; dockerClient.buildImageCmd() .withBaseDirectory(new File(baseDirectory)) .withDockerfile(new File(dockerfile)) .exec() .awaitImageId();
I get error: Could not build image: lstat target/app.jar: no such file or directory
I think there is bug in class Dockerfile.
In method processAddStatement() is line
src = new File(dockerFolder, resource);
and dockerFolder is parent directory of Dockerfile. IMO it is incorrect, it should be
src = new File(baseDirectory, resource);
where baseDirectory is directory passed to method withBaseDirectory() of BuildImageCmd.
From command line build works with command
docker build -f docker/Dockerfile .