sbt / sbt-native-packager

sbt Native Packager
https://sbt-native-packager.readthedocs.io/en/stable/
BSD 2-Clause "Simplified" License
1.59k stars 439 forks source link

Docker plugin doesn't copy files into image. #1468

Open ghost opened 2 years ago

ghost commented 2 years ago

Expected behaviour

When working with DockerPlugin, files in mapping aren't being copied to the image. I'm working with assembly plugin to create a fat jar, then adding it to Docker/mappings. (without archetype).

lazy val dockerSettings = Seq(Docker / mappings ++= Seq((assembly / assemblyOutputPath).value -> "/opt/tech/jobs/job.jar"))
...
.enablePlugins(DockerPlugin)
.settings(dockerSettings)

From sbt shell Docker/stage creates a Dockerfile and a directory with the jar from mappings.
Mappings from sbt shell shows the tuple. When Docker/publishLocal file is not being copied to the target directory.

Information

muuki88 commented 2 years ago

Hi @rapid-roman

Thanks for your issue report.

I would guess that the ordering of your settings is wrong or the scope.

  1. Enable the plugins first. SBT applies settings in order. However I'm not too sure about plugins.
  2. Use Universal / mappings. This setting is definitely used. I can't remember off the top of my head of this is added to the docker mappings ( which it definitely should )
ghost commented 2 years ago

@muuki88 I switched to the Universal / mappings instead of Docker / mappings and it fixed the issue. Not sure if the described behaviour is a bug or by design, since I enabled the plugin before the setting (see above). Thanks.