1

If I was running my application sans Docker, I would do something like this:

./myapp -Dconfig.file=conf/application.prod.conf -Dlogger.resource=logback.prod.xml

In fact, I can do even better and put them into by build.sbt file:

// Production Mode
javaOptions in Production ++= Seq(
  "-Dconfig.file=conf/application.prod.conf",
  "-Dlogger.resource=logback.prod.xml"
)

and then they will be applied when I run my app:

./myapp  # options now applied via build.sbt

When I build my app with sbt docker:publishLocal, then run it with docker run, the javaOptions do not take effect.

How can I get these javaOptions to take effect when I docker run ?

Raphael Mäder
  • 776
  • 5
  • 16
Tyler
  • 17,669
  • 10
  • 51
  • 89

2 Answers2

2

Found a work-around answer. You can set the dockerEntrypoint like so:

// build.sbt
dockerEntrypoint := Seq("bin/myapp", "-Dconfig.file=conf/application.prod.conf", "-Dlogger.resource=logback.prod.xml")
Tyler
  • 17,669
  • 10
  • 51
  • 89
1

javaOptions can be supplied to sbt-native-packager with

javaOptions in Universal ++= Seq(
  // -J params will be added as jvm parameters
  "-J-Xmx2048m",
  "-J-Xms256m"
)

Note that these options will be applied to all generated packages (Debian, Rpm, etc.), not just Docker. See the discussion here.

Raphael Mäder
  • 776
  • 5
  • 16