From b34256bf0c6e824290cd6c821f634447de8d2e4b Mon Sep 17 00:00:00 2001 From: Thanh Le Date: Sat, 11 May 2024 19:45:04 +0700 Subject: [PATCH 1/4] Support building local docker image --- build.sbt | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) 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") From d584e60fa6b753945d03f3b0f210c7c2c795cebc Mon Sep 17 00:00:00 2001 From: Thanh Le Date: Tue, 21 May 2024 09:58:48 +0700 Subject: [PATCH 2/4] Add docker workflows --- .github/workflows/docker.yml | 44 ++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .github/workflows/docker.yml 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 From a06ed644b79d9653f1be90285bb7b082a551cc6f Mon Sep 17 00:00:00 2001 From: Thanh Le Date: Tue, 21 May 2024 10:05:18 +0700 Subject: [PATCH 3/4] Try publish docker on pr --- .github/workflows/docker.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index c82f464a..8793ecd9 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -2,6 +2,8 @@ name: Create and publish a Docker image on: push: branches: [ "master" ] + pull_request: + branches: [ "master" ] env: REGISTRY: ghcr.io From 7927e9e46875a958994b9b8ef7d618c708f01842 Mon Sep 17 00:00:00 2001 From: Thanh Le Date: Tue, 21 May 2024 10:47:18 +0700 Subject: [PATCH 4/4] Revert "Try publish docker on pr" This reverts commit a06ed644b79d9653f1be90285bb7b082a551cc6f. Only publish on master --- .github/workflows/docker.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 8793ecd9..c82f464a 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -2,8 +2,6 @@ name: Create and publish a Docker image on: push: branches: [ "master" ] - pull_request: - branches: [ "master" ] env: REGISTRY: ghcr.io