Skip to content

Commit bf5a347

Browse files
committed
Tester flatjar.
1 parent 613c0bc commit bf5a347

File tree

2 files changed

+26
-9
lines changed

2 files changed

+26
-9
lines changed

Dockerfile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
FROM gcr.io/distroless/java17-debian11
2-
COPY build/libs/tms-varsel-api-all.jar app/app.jar
3-
ENV PORT=8080
4-
EXPOSE $PORT
5-
WORKDIR app
6-
CMD ["app.jar"]
1+
FROM ghcr.io/navikt/baseimages/temurin:21
2+
3+
ENV JAVA_OPTS='-XX:MaxRAMPercentage=75'
4+
5+
COPY build/libs/*.jar ./

build.gradle.kts

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat
33
plugins {
44
kotlin("jvm").version(Kotlin.version)
55

6-
id(Shadow.pluginId) version (Shadow.version)
7-
86
application
97
}
108

@@ -55,8 +53,10 @@ dependencies {
5553
testImplementation(Mockk.mockk)
5654
}
5755

56+
val projectMainClass = "no.nav.tms.varsel.api.ApplicationKt"
57+
5858
application {
59-
mainClass.set("no.nav.tms.varsel.api.ApplicationKt")
59+
mainClass.set(projectMainClass)
6060
}
6161

6262
tasks {
@@ -70,3 +70,21 @@ tasks {
7070
}
7171
}
7272
}
73+
74+
tasks {
75+
withType<Jar> {
76+
archiveBaseName.set("app")
77+
manifest {
78+
attributes["Main-Class"] = projectMainClass
79+
attributes["Class-Path"] = configurations.runtimeClasspath.get().joinToString(separator = " ") {
80+
it.name
81+
}
82+
}
83+
doLast {
84+
configurations.runtimeClasspath.get().forEach {
85+
val file = File("${layout.buildDirectory.get()}/libs/${it.name}")
86+
if (!file.exists()) it.copyTo(file)
87+
}
88+
}
89+
}
90+
}

0 commit comments

Comments
 (0)