Skip to content

Commit d5c6acb

Browse files
authored
Use distroless JDK17-image (#127)
1 parent 85664fe commit d5c6acb

File tree

6 files changed

+31
-7
lines changed

6 files changed

+31
-7
lines changed

.github/workflows/dispatch.yaml

+10-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
if: ${{ !env.found_image }}
2828
uses: actions/setup-java@v1
2929
with:
30-
java-version: '11.x'
30+
java-version: '17.x'
3131
- name: Checkout code
3232
if: ${{ !env.found_image }}
3333
uses: actions/checkout@v2
@@ -47,6 +47,15 @@ jobs:
4747
ORG_GRADLE_PROJECT_githubPassword: ${{ secrets.GITHUB_TOKEN }}
4848
run: |
4949
./gradlew shadowJar -x test
50+
- name: Install cosign
51+
if: ${{ !env.found_image }}
52+
uses: sigstore/cosign-installer@main
53+
with:
54+
cosign-release: 'v1.3.1'
55+
- name: Verify distroless base image
56+
if: ${{ !env.found_image }}
57+
run: |
58+
cosign verify --key distroless.pub gcr.io/distroless/java17
5059
- name: Build and publish Docker image if not already done
5160
if: ${{ !env.found_image }}
5261
env:

.github/workflows/main.yaml

+8-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- name: Setup java
1414
uses: actions/setup-java@v1
1515
with:
16-
java-version: '11.x'
16+
java-version: '17.x'
1717
- name: Checkout code
1818
uses: actions/checkout@v1
1919
- uses: actions/cache@v1
@@ -46,6 +46,13 @@ jobs:
4646
ORG_GRADLE_PROJECT_githubPassword: ${{ secrets.GITHUB_TOKEN }}
4747
run: |
4848
./gradlew shadowJar -x test
49+
- name: Install cosign
50+
uses: sigstore/cosign-installer@main
51+
with:
52+
cosign-release: 'v1.3.1'
53+
- name: Verify distroless base image
54+
run: |
55+
cosign verify --key distroless.pub gcr.io/distroless/java17
4956
- name: Build and publish Docker image
5057
env:
5158
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Dockerfile

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
FROM navikt/java:11
1+
FROM gcr.io/distroless/java17
2+
WORKDIR /app
23
COPY build/libs/app.jar app.jar
3-
ENV JAVA_OPTS="-Dlogback.configurationFile=logback.xml"
4-
ENV APPLICATION_PROFILE="remote"
4+
ENV JDK_JAVA_OPTIONS="-XX:MaxRAMPercentage=75 -Dlogback.configurationFile=logback.xml"
5+
ENV TZ="Europe/Oslo"
6+
EXPOSE 8080
7+
USER nonroot
8+
CMD [ "app.jar" ]

build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ tasks {
120120
}
121121

122122
withType<KotlinCompile> {
123-
kotlinOptions.jvmTarget = "11"
123+
kotlinOptions.jvmTarget = "17"
124124
}
125125

126126
withType<Test> {

distroless.pub

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-----BEGIN PUBLIC KEY-----
2+
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEWZzVzkb8A+DbgDpaJId/bOmV8n7Q
3+
OqxYbK0Iro6GzSmOzxkn+N2AKawLyXi84WSwJQBK//psATakCgAQKkNTAA==
4+
-----END PUBLIC KEY-----

src/main/kotlin/no/nav/syfo/App.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ fun main() {
5555

5656
applicationEngineEnvironment.monitor.subscribe(ApplicationStarted) { application ->
5757
applicationState.ready = true
58-
application.environment.log.info("Application is ready")
58+
application.environment.log.info("Application is ready, running Java VM ${Runtime.version()}")
5959
launchKafkaModule(
6060
applicationState = applicationState,
6161
environment = environment,

0 commit comments

Comments
 (0)