Skip to content

Commit

Permalink
docker deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
rpiaggio committed Feb 2, 2024
1 parent be77a8c commit 63caa9a
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 40 deletions.
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ New telescope control tool for the Gemini Observatory

# How to package for deployment

If you haven't already, create a symlink `jre` in the project directory that points to the Linux JRE you want bundled with the deployment.
The UI project (`navigate-ui`) must be in a sibling folder and be already built. See its README.md for instructions on how to build it.

Also, the UI project (`navigate-ui`) must be in a sibling folder and be already built. See its README.md for instructions on how to build it.

To deploy, run in `sbt`:
To build `navigate` Docker image in your local installation, run in `sbt`:

```
app_navigate_server/Universal/packageZipTarball
deploy_navigate_server/docker:publishLocal
```
26 changes: 9 additions & 17 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ ThisBuild / resolvers ++= Seq(

Global / resolvers ++= Resolver.sonatypeOssRepos("public")

ThisBuild / dockerExposedPorts ++= Seq(7070, 7071) // Must match deployed app.conf web-server.port
ThisBuild / dockerBaseImage := "eclipse-temurin:17-jre"

enablePlugins(GitBranchPrompt)

// Custom commands to facilitate web development
Expand Down Expand Up @@ -51,7 +54,7 @@ lazy val root = tlCrossRootProject.aggregate(
navigate_server,
navigate_web_server,
navigate_model,
app_navigate_server
deploy_navigate_server
)

lazy val epics = project
Expand Down Expand Up @@ -158,29 +161,18 @@ lazy val navigate_server = project
/**
* Project for the navigate server app for development
*/
lazy val app_navigate_server = preventPublication(project.in(file("app/navigate-server")))
lazy val deploy_navigate_server = preventPublication(project.in(file("deploy/navigate-server")))
.dependsOn(navigate_web_server)
.aggregate(navigate_web_server)
.enablePlugins(DockerPlugin)
.enablePlugins(JavaServerAppPackaging)
.enablePlugins(GitBranchPrompt)
.settings(navigateCommonSettings: _*)
.settings(releaseAppMappings: _*)
.settings(embeddedJreSettings: _*)
.settings(
description := "Navigate server for local testing",
// Put the jar files in the lib dir
Universal / mappings += {
val jar = (Compile / packageBin).value
jar -> ("lib/" + jar.getName)
},
Universal / mappings := {
// filter out sjs jar files. otherwise it could generate some conflicts
val universalMappings = (Universal / mappings).value
val filtered = universalMappings.filter { case (_, name) =>
!name.contains("_sjs")
}
filtered
},
description := "Navigate server",
Docker / packageName := "navigate-server",
dockerUpdateLatest := true,
Universal / mappings ++= {
// Navigate UI project must be in sibling folder and be already built. See its README.md.
val clientDir = (ThisBuild / baseDirectory).value.getParentFile / "navigate-ui" / "dist"
Expand Down
18 changes: 0 additions & 18 deletions project/AppsCommon.scala
Original file line number Diff line number Diff line change
Expand Up @@ -56,24 +56,6 @@ object AppsCommon {
}
)

lazy val embeddedJreSettings = Seq(
// Put the jre in the tarball
Universal / mappings ++= {
// We look for the JRE in the project's base directory. This can be a symlink.
val jreDir = (ThisBuild / baseDirectory).value / "jre"
if (!jreDir.exists)
throw new Exception("JRE directory does not exist: " + jreDir)
directory(jreDir).map { path =>
path._1 -> ("jre/" + path._1.relativeTo(jreDir).get.getPath)
}
},

// Make the launcher use the embedded jre
Universal / javaOptions ++= Seq(
"-java-home ${app_home}/../jre"
)
)

/**
* Settings for meta projects to make them non-publishable
*/
Expand Down

0 comments on commit 63caa9a

Please sign in to comment.