dockerscalasbtsbt-native-packager

SBT Native Packager Add File Using Docker Command


I'm using the SBT Native Packager to add a file from the local file system to the generated Dockerfile as below:

dockerCommands += Cmd("ADD", "./data/housing.tgz /opt/docker/data/housing.tgz"),

But for some wierd reasons, it fails with the following error message:

error] ADD failed: file not found in build context or excluded by .dockerignore: stat data/housing.tgz: file does not exist
[info] Removing intermediate image(s) (labeled "snp-multi-stage-id=3c44b7e0-11bf-4046-86f3-92c264045b3c") 
[info] Deleted Images:
[info] deleted: sha256:863f281d9b1b70b3c6a15c5490c611871c0983606ce26db81ed23cb59b78d135
[info] deleted: sha256:d883508446a9dedc50648acd5bf857d6c9ce9076901ad30452d517a9c6f282e3
[info] deleted: sha256:0f4346ae03f79736d8fc6464b4666c3d50b0eb41e7babd084550e6d7216b909f
[info] deleted: sha256:81f34527c19a680b95c8554c8da3cdbaf8477ad404632e064256d69df40fcbdc
[info] deleted: sha256:6d51064d13b2d0e5f1b8c3198a55ff8c614acfa0f47a27c3414ee4b9db440691
[info] deleted: sha256:19f83ef7b1860f577d9011981c94de80f59b60349e7db7a76f05262673f2a41d
[info] deleted: sha256:e143da4df939bd15b45f9bcdd19b9a687b60fbe7e44b0273372c82b20e26f775
[info] deleted: sha256:a7489b5df78ae72971f9ceb00b2236cd4656fe949037b12d5f1cfa6091c8a942
[info] deleted: sha256:9de911e46b6c5d1579345149b409b81e48a031a33778b795bd87ac0b8c524822
[info] deleted: sha256:ea2c1827b49771ace1bfb6e20d8b16348d4b1b7d68e6580542126b5cf80eb514
[info] deleted: sha256:95e1f59a1c38c09cb178eb1d1895ec773e583ee98d4e1920ffc52e0fef020b26
[info] deleted: sha256:42f8962f7f8f9302f74c989fcb5470ade34cee9d7c4f3a485b89702fa2242895
[info] deleted: sha256:29293c732f8be07cee0e6ff813b67a788c80ed106911e51b0caf0db1adc456cb
[info] deleted: sha256:9bce83c73ad1e2467f847a8127f5990a698493353f4b22a0b5a82a00574ec11a
[info] deleted: sha256:51b982a314598ab0c06210d84b4236c6d4a2a4fd89c16817f05e14b8d9102c0c
[info] Total reclaimed space: 235.4MB
[error] java.lang.RuntimeException: Nonzero exit value: 1

Solution

  • If i remember correctly docker image staging is from target folder. I think dockerCommand is executed in target folder, so if your file is in main root project then you should add this file to be added in target too or change path to access it like ./../[repeat .. if necessary]/data/housing.tgz to get the file.