Skip to content

Commit

Permalink
fix jib docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
merlijn committed Dec 22, 2024
1 parent 614dadd commit a0a8c0e
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 58 deletions.
17 changes: 0 additions & 17 deletions Dockerfile

This file was deleted.

20 changes: 6 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ docker pull europe-west4-docker.pkg.dev/amony-04c85b/docker-images/amony/app:lat

### 2. Run the docker image

The default location for the media files is `/amony/media`. You can mount a local directory to it.
The default location for the solr index, database and config files is `/amony/data`. It is recommended to mount a local directory to it to persist the data.
The default location for the media files is `/media`. You can mount a local directory to it.
The default location for the solr index, database and config files is `/app/data`. It is recommended to mount a local directory to it to persist the data.

```bash
docker run -v /path/to/my/media:/amony/media -v /path/to/my/amony-data:/amony/data -p 8080:8080 --name amony europe-west4-docker.pkg.dev/amony-04c85b/docker-images/amony/app:latest
docker run -v /path/to/my/media:/media -v /path/to/my/amony-data:/app/data -p 8080:8080 --name amony europe-west4-docker.pkg.dev/amony-04c85b/docker-images/amony/amony-app:latest
```

### 3. Usage
Expand Down Expand Up @@ -93,23 +93,15 @@ npm install --save
npm run build
```

### 2. Build the server
### 2. Build the docker image

```
cd server
sbt assembly
sbt web-server/jibDockerBuild
```

### 3. Build the docker image

```
docker build -t my-amony-app:latest .
```

The first time this can take a bit longer since it downloads & installs all dependencies for `ffmpeg`.

### 4. Run the docker image

```bash
docker run -v /path/to/my/media:/amony/media -v /path/to/my/amony-data:/amony/data -p 8080:8080 my-amony-app:latest
docker run -v /path/to/my/media:/media -v /path/to/my/amony-data:/app/data -p 8080:8080 --name amony europe-west4-docker.pkg.dev/amony-04c85b/docker-images/amony/amony-app:latest
```
44 changes: 20 additions & 24 deletions server/build.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//import sbt.Keys.scalaVersion
import sbtassembly.AssemblyPlugin.autoImport.assemblyMergeStrategy
import com.google.cloud.tools.jib.api.buildplan.Platform
import de.gccc.jib.MappingsHelper

// --- Dependencies

Expand All @@ -22,7 +24,7 @@ val slickHikariCp = "com.typesafe.slick" %% "slick-hikaricp"

val jwtCirce = "com.github.jwt-scala" %% "jwt-circe" % "10.0.1"
val slf4jApi = "org.slf4j" % "slf4j-api" % "2.0.16"
val scribeSlf4j = "com.outr" %% "scribe-slf4j" % "3.15.2"
val scribeSlf4j = "com.outr" %% "scribe-slf4j" % "3.15.3"

val fs2Core = "co.fs2" %% "fs2-core" % "3.11.0"
val fs2Io = "co.fs2" %% "fs2-io" % "3.11.0"
Expand Down Expand Up @@ -247,25 +249,31 @@ lazy val amonyServer =
run / javaOptions ++= javaOpts,
outputStrategy := Some(StdoutOutput),

jibBaseImage := "europe-west4-docker.pkg.dev/amony-04c85b/docker-images/amony/base:latest",
// jibPlatforms := Set("linux/amd64"),
jibImageFormat := JibImageFormat.Docker,
jibRegistry := "europe-west4-docker.pkg.dev",
jibName := "amony-app",
jibTags := List("latest"),
jibEntrypoint := Some(List("java", "-jar", "/amony.jar")),
jibCustomRepositoryPath := Some("amony-04c85b/docker-images/amony"),
jibBaseImage := "europe-west4-docker.pkg.dev/amony-04c85b/docker-images/amony/base:latest",
jibRegistry := "europe-west4-docker.pkg.dev",
jibName := "amony-app",
jibCustomRepositoryPath := Some("amony-04c85b/docker-images/amony/" + jibName.value),
jibPlatforms := Set(new Platform("amd64", "linux")),
jibImageFormat := JibImageFormat.Docker,
jibTags := List("latest"),
jibExtraMappings ++= {
// this adds the frontend assets to the docker image
val webClientDir = (Compile / baseDirectory).value / ".." / ".." / "web-client" / "dist"
val target = "/app/web-client"
MappingsHelper.contentOf(webClientDir, target)
},
jibEnvironment := Map("JAVA_TOOL_OPTIONS" -> "-Dconfig.file=/app/resources/prod/application.conf"),
jibUseCurrentTimestamp := true,

Compile / packageBin / mainClass := Some("nl.amony.webserver.WebServer"),
Compile / packageBin / mainClass := Some("nl.amony.webserver.Main"),

libraryDependencies ++= Seq(
// logging
slf4jApi, scribeSlf4j, log4CatsSlf4j,
// config loading
typesafeConfig, pureConfig,
// database
liquibaseCore, slickHikariCp, hsqlDB, h2DB,
circe, circeGeneric, circeParser,
slickHikariCp, hsqlDB, h2DB,
fs2Core,
http4sEmberServer,
// test
Expand All @@ -275,18 +283,6 @@ lazy val amonyServer =
excludeDependencies ++= List(
ExclusionRule("javax.xml.bind", "jaxb-api"),
),

// assembly / logLevel := Level.Debug,
assembly / assemblyJarName := "amony.jar",
assembly / assemblyMergeStrategy := {
case s if s.endsWith("module-info.class") => MergeStrategy.discard
case s if s.endsWith("Log4j2Plugins.dat") => MergeStrategy.discard
case s if s.startsWith("org/iq80/leveldb") => MergeStrategy.first
case s if s.endsWith("io.netty.versions.properties") => MergeStrategy.first
case x =>
val oldStrategy = (assembly / assemblyMergeStrategy).value
oldStrategy(x)
}
)

lazy val amony = project
Expand Down
1 change: 1 addition & 0 deletions server/project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ addSbtPlugin("io.spray" % "sbt-revolver" % "0.9.1")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "1.0.0")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")
addSbtPlugin("de.gccc.sbt" % "sbt-jib" % "1.3.7")
addSbtPlugin("com.github.cb372" % "sbt-explicit-dependencies" % "0.3.1")
libraryDependencies += "com.google.cloud.tools" % "jib-core" % "0.27.2"
6 changes: 3 additions & 3 deletions server/web-server/src/main/resources/prod/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ include required(classpath("amony-common.conf"))

amony {

amony-home = "/amony"
amony-home = "/app"
amony-home = ${?AMONY_HOME}

api {
host-name = localhost
web-client-path = ${amony.amony-home}"/app/web-client"
web-client-path = ${amony.amony-home}"/web-client"
}

solr {
Expand Down Expand Up @@ -39,7 +39,7 @@ amony {
type = "local-directory-config"

# location of your media
path = "/amony/media"
path = "/media"

# path where to write derived resources such as thumbnails and video fragments
relative-cache-path = ".amony/cache"
Expand Down

0 comments on commit a0a8c0e

Please sign in to comment.