diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 00000000..c82f464a --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,44 @@ +name: Create and publish a Docker image +on: + push: + branches: [ "master" ] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + + steps: + + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup JVM + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 21 + cache: sbt + + - name: Log in to the Container registry + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + run: sbt Docker/publish diff --git a/build.sbt b/build.sbt index ea401731..0fadaf86 100644 --- a/build.sbt +++ b/build.sbt @@ -3,7 +3,9 @@ inThisBuild( scalaVersion := "3.4.2", versionScheme := Some("early-semver"), version := "3.2", - semanticdbEnabled := true // for scalafix + semanticdbEnabled := true, // for scalafix + dockerBaseImage := "openjdk:21", + dockerUpdateLatest := true ) ) @@ -18,7 +20,7 @@ val chessVersion = "16.0.3" lazy val `lila-ws` = project .in(file(".")) - .enablePlugins(JavaAppPackaging) + .enablePlugins(JavaAppPackaging, DockerPlugin) .settings( name := "lila-ws", organization := "org.lichess", @@ -63,7 +65,13 @@ lazy val `lila-ws` = project "-Xtarget:21", "-Wunused:all" ), - javaOptions ++= Seq("-Xms32m", "-Xmx256m") + javaOptions ++= Seq("-Xms32m", "-Xmx256m"), + Docker / packageName := "lichess-org/lila-ws", + Docker / maintainer := "lichess.org", + Docker / dockerRepository := Some("ghcr.io"), + Universal / javaOptions := Seq( + "-J-Dconfig.override_with_env_vars=true" + ) ) addCommandAlias("prepare", "scalafixAll; scalafmtAll")