Skip to content

Commit

Permalink
Merge pull request #566 from lichess-org/support-build-local-docker-i…
Browse files Browse the repository at this point in the history
…mage

Publish docker image
  • Loading branch information
ornicar authored May 21, 2024
2 parents b96adfd + 7927e9e commit a62e5c7
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 3 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -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
14 changes: 11 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
)

Expand All @@ -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",
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit a62e5c7

Please sign in to comment.