use ktor native fatJar task

This commit is contained in:
2026-08-03 16:58:25 +03:00
parent 6a77e0c668
commit 986078a84c
2 changed files with 13 additions and 20 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
FROM bellsoft/liberica-openjdk-alpine:21
WORKDIR /usr/local/app
COPY ./build/libs/server-fat-1.0.jar ./server-fat-1.0.jar
COPY ./build/libs/server-fat.jar ./server-fat.jar
EXPOSE 8181
CMD ["java", "-jar", "server-fat-1.0.jar"]
CMD ["java", "-jar", "server-fat.jar"]
+11 -18
View File
@@ -64,25 +64,18 @@ application {
applicationDefaultJvmArgs = listOf("-Dio.ktor.development=$isDevelopment")
}
ktor {
fatJar {
archiveFileName.set("server-fat.jar")
}
}
tasks {
register("fatJar", Jar::class) {
archiveBaseName = "server-fat"
manifest {
attributes["Implementation-Title"] = "Videobox Server"
attributes["Implementation-Version"] = version
attributes["Main-Class"] = mainClassName
}
from(configurations.runtimeClasspath.get().map { if (it.isDirectory) it else zipTree(it) })
duplicatesStrategy = DuplicatesStrategy.WARN
with(jar.get() as CopySpec)
named("build") {
dependsOn("buildFatJar")
}
"build" {
dependsOn("fatJar")
}
register<Exec>("deployRemote") {
dependsOn("fatJar")
dependsOn("buildFatJar")
commandLine(
getCommandLine(
"docker context use remote",
@@ -92,9 +85,8 @@ tasks {
)
notCompatibleWithConfigurationCache("This task uses Exec which is not compatible with configuration cache")
}
register<Exec>("deployLocal") {
dependsOn("fatJar")
dependsOn("buildFatJar")
commandLine(
getCommandLine(
"docker compose down",
@@ -104,6 +96,7 @@ tasks {
notCompatibleWithConfigurationCache("This task uses Exec which is not compatible with configuration cache")
}
}
private fun getCommandLine(vararg commands: String): List<String> {
val osName = System.getProperty("os.name").lowercase()
return if (osName.contains("win")) {