Skip to content

Commit

Permalink
Merge pull request #338 from NDLANO/memory-adjustability
Browse files Browse the repository at this point in the history
Allow `JAVA_OPTS` flag to docker containers
  • Loading branch information
jnatten authored Nov 15, 2023
2 parents be8fbca + add4927 commit e371b6a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
13 changes: 4 additions & 9 deletions project/Module.scala
Original file line number Diff line number Diff line change
Expand Up @@ -128,25 +128,20 @@ trait Module {
"--add-opens=java.desktop/java.awt=ALL-UNNAMED"
)

def dockerSettings(extraJavaOpts: String*): Seq[Def.Setting[_]] = {
def dockerSettings(): Seq[Def.Setting[_]] = {
Seq(
docker := (docker dependsOn assembly).value,
docker / dockerfile := {
val artifact = (assembly / assemblyOutputPath).value
val artifactTargetPath = s"/app/${artifact.name}"

val entry = Seq(
"java",
"-Dorg.scalatra.environment=production"
) ++
reflectiveAccessOptions ++
extraJavaOpts ++
Seq("-jar", artifactTargetPath)
val entry =
s"java -Dorg.scalatra.environment=production $$JAVA_OPTS ${reflectiveAccessOptions.mkString(" ")} -jar $artifactTargetPath"

new Dockerfile {
from("eclipse-temurin:20-jdk")
add(artifact, artifactTargetPath)
entryPoint(entry: _*)
entryPointRaw(entry)
}
},
docker / imageNames := Seq(
Expand Down
2 changes: 1 addition & 1 deletion project/imageapi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ object imageapi extends Module {
libraryDependencies ++= dependencies
) ++
commonSettings ++
dockerSettings("-Xmx6G") ++
dockerSettings() ++
tsSettings ++
assemblySettings()

Expand Down
2 changes: 1 addition & 1 deletion project/searchapi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ object searchapi extends Module {
) ++
commonSettings ++
assemblySettings() ++
dockerSettings("-Xmx6G") ++
dockerSettings() ++
tsSettings

override lazy val plugins: Seq[sbt.Plugins] = Seq(
Expand Down

0 comments on commit e371b6a

Please sign in to comment.