From 71963f348a61159e9c37834fb1a72a9c65c62410 Mon Sep 17 00:00:00 2001 From: Gus Hahn-Powell Date: Wed, 30 Mar 2022 21:26:32 -0700 Subject: [PATCH 1/2] Change base image to arm64/amd64 compat --- build.sbt | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/build.sbt b/build.sbt index b0260cf1..ef7c94cc 100644 --- a/build.sbt +++ b/build.sbt @@ -62,9 +62,13 @@ lazy val extra = project // Docker settings val gitDockerTag = settingKey[String]("Git commit-based tag for docker") ThisBuild / gitDockerTag := { - val shortHash: String = git.gitHeadCommit.value.get.take(7) - val uncommittedChanges: Boolean = (git.gitUncommittedChanges).value - s"""${shortHash}${if (uncommittedChanges) "-DIRTY" else ""}""" + git.gitHeadCommit.value match { + case Some(commit) => + val shortHash: String = commit.take(7) + val uncommittedChanges: Boolean = (git.gitUncommittedChanges).value + s"""${shortHash}${if (uncommittedChanges) "-DIRTY" else ""}""" + case None => "latest" + } } lazy val generalDockerSettings = { @@ -72,14 +76,15 @@ lazy val generalDockerSettings = { ThisBuild / parallelExecution := false, // see https://www.scala-sbt.org/sbt-native-packager/formats/docker.html Docker / daemonUserUid := None, - Docker / daemonUser := "root", + Docker / daemonUser := "odinson", + Docker / packageName := "odinson-rest-api", + dockerBaseImage := "eclipse-temurin:11-jre-focal", // arm46 and amd64 compat dockerUsername := Some("lumai"), dockerAliases ++= Seq( dockerAlias.value.withTag(Option("latest")), dockerAlias.value.withTag(Option(gitDockerTag.value)) ), Docker / maintainer := "Gus Hahn-Powell ", - dockerBaseImage := "adoptopenjdk/openjdk11", Universal / javaOptions ++= Seq( "-Dodinson.dataDir=/app/data/odinson" ) From 8c8035c763a91b5d9a8c69ed6bcbcabec71a5f40 Mon Sep 17 00:00:00 2001 From: Gus Hahn-Powell Date: Thu, 31 Mar 2022 00:07:55 -0700 Subject: [PATCH 2/2] Disable ARM64 Relates to https://github.com/clulab/processors/pull/598 --- .github/workflows/docker.yml | 4 +++- build.sbt | 5 +++-- docs/docker.md | 6 +++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 2f98c85d..6cf6a71c 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -78,8 +78,10 @@ jobs: env: IMAGE_NAME: "odinson-extras" # --output=type=docker + # FIXME: temporary disable ARM64 publishing until next version of processors is released (see https://github.com/clulab/processors/pull/598) run: | - docker buildx build --platform=linux/amd64,linux/arm64 -f ${{ env.DOCKERFILE }} --push -t "${{ env.ORG }}/$IMAGE_NAME:latest" -t "${{ env.ORG }}/$IMAGE_NAME:${{ needs.setup.outputs.sha_short }}" . + docker buildx build --platform=linux/amd64 -f ${{ env.DOCKERFILE }} --push -t "${{ env.ORG }}/$IMAGE_NAME:latest" -t "${{ env.ORG }}/$IMAGE_NAME:${{ needs.setup.outputs.sha_short }}" . + #docker buildx build --platform=linux/amd64,linux/arm64 -f ${{ env.DOCKERFILE }} --push -t "${{ env.ORG }}/$IMAGE_NAME:latest" -t "${{ env.ORG }}/$IMAGE_NAME:${{ needs.setup.outputs.sha_short }}" . # # publish # - name: "Publish docker `lumai/odinson-extras` image" # env: diff --git a/build.sbt b/build.sbt index ef7c94cc..ac93b814 100644 --- a/build.sbt +++ b/build.sbt @@ -75,8 +75,8 @@ lazy val generalDockerSettings = { Seq( ThisBuild / parallelExecution := false, // see https://www.scala-sbt.org/sbt-native-packager/formats/docker.html - Docker / daemonUserUid := None, - Docker / daemonUser := "odinson", + Docker / daemonUserUid := Some("1002"), + Docker / daemonUser := "odinson", Docker / packageName := "odinson-rest-api", dockerBaseImage := "eclipse-temurin:11-jre-focal", // arm46 and amd64 compat dockerUsername := Some("lumai"), @@ -137,4 +137,5 @@ ThisBuild / developers := List( // tasks addCommandAlias("dockerize", ";clean;compile;test;docker:publishLocal") +addCommandAlias("dockerfile", ";clean;compile;docker:stage") addCommandAlias("dockerizeAndPublish", ";clean;compile;test;docker:publish") diff --git a/docs/docker.md b/docs/docker.md index d5bc5be6..1a48efec 100644 --- a/docs/docker.md +++ b/docs/docker.md @@ -27,13 +27,13 @@ See [our repository](https://hub.docker.com/r/lumai/odinson-extras) for other ta ### Annotating text using the docker image ```bash -docker run \ +docker run --platform linux/amd64 \ --name="odinson-extras" \ -it \ --rm \ -e "HOME=/app" \ - -e "JAVA_OPTS=-Dodinson.extra.processorType=CluProcessor" \ - -v "/path/to/data/odinson:/app/data/odinson" \ + -e "JAVA_OPTS=-Xmx4G -Dodinson.extra.processorType=CluProcessor" \ + -v "${PWD}/extra/src/test/resources:/app/data/odinson" \ --entrypoint "bin/annotate-text" \ "lumai/odinson-extras:latest" ```