Skip to content

Commit 88446e6

Browse files
authored
Upgrade Java version to 17 in Dockerfile (#1195)
Motivation: The latest Central Dogma docker image failes to start up on the `ubuntu-latest` image of GitHub Actions due to the following NPE: ``` Error: -20 09:22:41.518 [ERROR](c.l.c.s.Main) [main] Failed to start the Central Dogma: java.util.concurrent.ExecutionException: java.lang.NullPointerException at java.base/java.util.concurrent.CompletableFuture.reportGet(Unknown Source) at java.base/java.util.concurrent.CompletableFuture.get(Unknown Source) at com.linecorp.armeria.common.util.EventLoopCheckingFuture.get(EventLoopCheckingFuture.java:73) at com.linecorp.centraldogma.server.Main.start(Main.java:138) at com.linecorp.centraldogma.server.Main.main(Main.java:238) Caused by: java.lang.NullPointerException: null at java.base/jdk.internal.platform.cgroupv2.CgroupV2Subsystem.getInstance(Unknown Source) at java.base/jdk.internal.platform.CgroupSubsystemFactory.create(Unknown Source) at java.base/jdk.internal.platform.CgroupMetrics.getInstance(Unknown Source) at java.base/jdk.internal.platform.SystemMetrics.instance(Unknown Source) at java.base/jdk.internal.platform.Metrics.systemMetrics(Unknown Source) at java.base/jdk.internal.platform.Container.metrics(Unknown Source) at jdk.management/com.sun.management.internal.OperatingSystemImpl.<init>(Unknown Source) at jdk.management/com.sun.management.internal.PlatformMBeanProviderImpl.getOperatingSystemMXBean(Unknown Source) at jdk.management/com.sun.management.internal.PlatformMBeanProviderImpl$3.nameToMBeanMap(Unknown Source) at java.management/sun.management.spi.PlatformMBeanProvider$PlatformComponent.getMBeans(Unknown Source) at java.management/java.lang.management.ManagementFactory.getPlatformMXBean(Unknown Source) at java.management/java.lang.management.ManagementFactory.getOperatingSystemMXBean(Unknown Source) at io.micrometer.core.instrument.binder.system.FileDescriptorMetrics.<init>(FileDescriptorMetrics.java:78) at io.micrometer.core.instrument.binder.system.FileDescriptorMetrics.<init>(FileDescriptorMetrics.java:74) at com.linecorp.centraldogma.server.CentralDogma.configureMetrics(CentralDogma.java:1130) at com.linecorp.centraldogma.server.CentralDogma.startServer(CentralDogma.java:772) at com.linecorp.centraldogma.server.CentralDogma.doStart(CentralDogma.java:474) at com.linecorp.centraldogma.server.CentralDogma.access$800(CentralDogma.java:198) at com.linecorp.centraldogma.server.CentralDogma$CentralDogmaStartStop.lambda$doStart$0(CentralDogma.java:1306) at com.linecorp.centraldogma.server.CentralDogma$CentralDogmaStartStop.lambda$execute$2(CentralDogma.java:1345) at java.base/java.lang.Thread.run(Unknown Source) ``` The exception seems fixed by https://bugs.openjdk.org/browse/JDK-8287073, so upgrading Java version will solve the issue. Related: line/centraldogma-python#70 Modifications: - Upgrade the JRE version of the Docker image to 17 - Add a CI test to check if Central Dogma docker images start successfully. Result: Central Dogma Docker image now starts up properly in GitHub Actions. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Added a CI workflow that builds Docker images and verifies them by bringing up and health-checking the compose services. * Updated the build environment to use a modern JDK, configured build tooling, and increased job timeout to support image builds and integration checks. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent da26ea4 commit 88446e6

4 files changed

Lines changed: 83 additions & 35 deletions

File tree

.github/workflows/actions_build.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,40 @@ jobs:
190190
run: |
191191
./gradlew --no-daemon --stacktrace check -PnoLint -PflakyTests=true
192192
shell: bash
193+
194+
docker-build:
195+
if: github.repository == 'line/centraldogma'
196+
runs-on: ubuntu-latest
197+
timeout-minutes: 60
198+
env:
199+
GRADLE_OPTS: -Xmx1280m
200+
steps:
201+
- uses: actions/checkout@v3
202+
203+
- id: setup-jdk
204+
name: Set up JDK ${{ env.BUILD_JDK_VERSION }}
205+
uses: actions/setup-java@v3
206+
with:
207+
distribution: 'temurin'
208+
java-version: ${{ env.BUILD_JDK_VERSION }}
209+
210+
- name: Setup Gradle
211+
uses: gradle/gradle-build-action@v2
212+
213+
- name: Set up QEMU
214+
uses: docker/setup-qemu-action@v3
215+
216+
- name: Set up Docker Buildx
217+
uses: docker/setup-buildx-action@v3
218+
219+
- name: Build Docker Image
220+
run: |
221+
./gradlew :dist:docker --stacktrace -Pversion=test
222+
docker images
223+
224+
- name: Test DockerCompose
225+
# Make sure Central Dogma docker container can be started and healthy.
226+
run: |
227+
docker compose -f dist/docker-compose-test.yml up --pull never --wait -d
228+
docker compose -f dist/docker-compose-test.yml down
229+
shell: bash

dist/Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#
22
# CentralDogma Dockerfile
33
#
4-
FROM openjdk:11-jre
4+
FROM eclipse-temurin:17-jre
55

66
# Multi-platform build arguments (pre-defined by docker)
77
ARG TARGETARCH
@@ -37,5 +37,9 @@ COPY --chmod=755 \
3737
# Expose ports.
3838
EXPOSE 36462
3939

40+
# Healthcheck – waits for the HTTP API to respond
41+
HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=10 \
42+
CMD curl -f http://127.0.0.1:36462/monitor/l7check || exit 1
43+
4044
# Entrypoint doesn't allow an environment variable.
4145
ENTRYPOINT ["/opt/centraldogma/bin/startup", "-nodetach"]

dist/build.gradle

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ dependencies {
4040
tasks.jar.enabled = false
4141

4242
task copyLicenses(group: 'Build',
43-
description: "Copies license information into ${project.ext.relativeDistDir}/licenses",
44-
type: Copy) {
43+
description: "Copies license information into ${project.ext.relativeDistDir}/licenses",
44+
type: Copy) {
4545

4646
from "${rootProject.projectDir}"
4747
into "${project.ext.distDir}"
@@ -52,9 +52,9 @@ task copyLicenses(group: 'Build',
5252
}
5353

5454
task copyLib(group: 'Build',
55-
description: "Copies JARs into ${project.ext.relativeDistDir}/lib",
56-
dependsOn: project(':server').tasks.jar,
57-
type: Copy) {
55+
description: "Copies JARs into ${project.ext.relativeDistDir}/lib",
56+
dependsOn: project(':server').tasks.jar,
57+
type: Copy) {
5858

5959
from configurations.runtimeClasspath
6060
File libDir = new File("${project.ext.distDir}/lib")
@@ -159,8 +159,8 @@ task distDirWithoutClientBinaries(group: 'Build',
159159
}
160160

161161
task distDir(group: 'Build',
162-
description: "Builds a distribution directory (${project.ext.relativeDistDir})",
163-
dependsOn: [tasks.copyLicenses, tasks.copyLib, tasks.copyClientBinaries])
162+
description: "Builds a distribution directory (${project.ext.relativeDistDir})",
163+
dependsOn: [tasks.copyLicenses, tasks.copyLib, tasks.copyClientBinaries])
164164

165165
// Create the tasks that copy each directory under src/ into dist/
166166
['bin', 'conf'].each { dirName ->
@@ -174,9 +174,9 @@ task distDir(group: 'Build',
174174
}
175175

176176
task tarball(group: 'Build',
177-
description: "Builds a tarball from the distribution directory (${project.ext.relativeDistDir})",
178-
dependsOn: tasks.distDir,
179-
type: Tar) {
177+
description: "Builds a tarball from the distribution directory (${project.ext.relativeDistDir})",
178+
dependsOn: tasks.distDir,
179+
type: Tar) {
180180

181181
archiveBaseName = rootProject.name
182182
destinationDirectory = project.file("${project.buildDir}")
@@ -196,53 +196,57 @@ tasks.assemble.dependsOn(tasks.tarball)
196196

197197
// Tasks for building docker image
198198
task docker(group: 'Build',
199-
description: "Builds multiplatform docker image from the distribution directory" +
200-
" (${project.ext.relativeDistDir})",
201-
dependsOn: tasks.distDir,
202-
type: Exec) {
199+
description: "Builds multiplatform docker image from the distribution directory" +
200+
" (${project.ext.relativeDistDir})",
201+
dependsOn: tasks.distDir,
202+
type: Exec) {
203203

204204
workingDir = file('.')
205205
executable 'docker'
206206

207207
def imageName = 'ghcr.io/line/centraldogma'
208208
def imageVersion = project.hasProperty('version') ? project.getProperty('version') : project.version
209-
def platforms = ['linux/amd64', 'linux/arm64']
210-
211-
def buildArgs = [
212-
'buildx', 'build',
213-
'--platform', platforms.join(','),
214-
'--push'
215-
]
216-
217-
buildArgs.add("--tag")
218-
buildArgs.add("${imageName}:${imageVersion}")
219-
if (!(project.version =~ /-SNAPSHOT$/)) {
220-
buildArgs.add("--tag")
221-
buildArgs.add("${imageName}:latest")
209+
def buildArgs = ['buildx', 'build']
210+
if (imageVersion == 'test') {
211+
buildArgs.addAll([
212+
'--platform', 'linux/amd64',
213+
'--load',
214+
"--tag", "${imageName}:${imageVersion}"
215+
])
216+
} else {
217+
buildArgs.addAll([
218+
'--platform', 'linux/amd64,linux/arm64',
219+
'--push',
220+
"--tag", "${imageName}:${imageVersion}"
221+
])
222+
if (!(project.version =~ /-SNAPSHOT$/)) {
223+
buildArgs.addAll(["--tag", "${imageName}:latest"])
224+
}
222225
}
226+
223227
buildArgs.add('.')
224228

225229
args = buildArgs
226230
}
227231

228232
// Tasks for running Central Dogma conveniently.
229233
task startup(group: 'Execution',
230-
description: "Starts up Central Dogma at ${project.ext.relativeDistDir}",
231-
dependsOn: tasks.distDir,
232-
type: Exec) {
234+
description: "Starts up Central Dogma at ${project.ext.relativeDistDir}",
235+
dependsOn: tasks.distDir,
236+
type: Exec) {
233237

234238
commandLine "${project.ext.distDir}/bin/startup"
235239
}
236240

237241
task shutdown(group: 'Execution',
238-
description: "Shuts down Central Dogma at ${project.ext.relativeDistDir}",
239-
type: Exec) {
242+
description: "Shuts down Central Dogma at ${project.ext.relativeDistDir}",
243+
type: Exec) {
240244

241245
commandLine "${project.ext.distDir}/bin/shutdown"
242246
}
243247

244248
tasks.startup.mustRunAfter(tasks.shutdown)
245249

246250
task restart(group: 'Execution',
247-
description: "Restarts Central Dogma at ${project.ext.relativeDistDir}",
248-
dependsOn: [tasks.shutdown, tasks.startup])
251+
description: "Restarts Central Dogma at ${project.ext.relativeDistDir}",
252+
dependsOn: [tasks.shutdown, tasks.startup])

dist/docker-compose-test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
services:
2+
centraldogma:
3+
image: ghcr.io/line/centraldogma:test

0 commit comments

Comments
 (0)