Skip to content

Commit

Permalink
Spring Reactive (Native as well) are actualized.
Browse files Browse the repository at this point in the history
  • Loading branch information
vadzimkavalkou committed Nov 16, 2023
1 parent 0549f9f commit 069a8db
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 95 deletions.
43 changes: 0 additions & 43 deletions spring-boot-reactive-native/build.gradle

This file was deleted.

70 changes: 70 additions & 0 deletions spring-boot-reactive-native/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
plugins {
java
application
id("org.springframework.boot") version "3.1.5"
id("io.spring.dependency-management") version "1.1.4"
id("org.graalvm.buildtools.native") version "0.9.28"
id("com.google.cloud.tools.jib") version "3.4.0"
}

group = "by.vk"
version = "1.0.0-RC1"

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

configurations {
compileOnly {
extendsFrom(configurations.annotationProcessor.get())
}
}

springBoot {
buildInfo()
}

repositories {
mavenCentral()
}

dependencies {
//region spring
implementation("org.springframework.boot:spring-boot-starter-data-r2dbc")
implementation("org.springframework.boot:spring-boot-starter-webflux")
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("org.springframework.boot:spring-boot-starter-validation")
//endregion
//region logback
implementation("ch.qos.logback.contrib:logback-jackson:0.1.5")
implementation("ch.qos.logback.contrib:logback-json-classic:0.1.5")
//endregion
//region lombok
annotationProcessor("org.projectlombok:lombok")
implementation("org.projectlombok:lombok")
//endregion
//region postgres
implementation("io.r2dbc:r2dbc-postgresql:0.8.13.RELEASE")
//endregion
}

tasks.bootBuildImage {
buildpacks.set(listOf("gcr.io/paketo-buildpacks/java-native-image:latest"))
builder.set("paketobuildpacks/builder:tiny")
environment.set(mapOf("BP_NATIVE_IMAGE" to "true"))
}

jib {
to {
image = "srn-service:latest"
}
from {
image = "gcr.io/distroless/java17:latest"
}
container {
ports = listOf("8080")
labels.set(mapOf("appname" to application.applicationName, "version" to version.toString(), "maintainer" to "Vadzim Kavalkou <vadzim.kavalkou@gmail.com>"))
creationTime.set("USE_CURRENT_TIMESTAMP")
}
}
52 changes: 0 additions & 52 deletions spring-boot-reactive/build.gradle

This file was deleted.

93 changes: 93 additions & 0 deletions spring-boot-reactive/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
plugins {
java
application
id("org.springframework.boot") version "3.1.5"
id("io.spring.dependency-management") version "1.1.4"
id("com.google.cloud.tools.jib") version "3.4.0"
}

group = "by.vk"
version = "1.0.0-RC1"

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

configurations {
compileOnly {
extendsFrom(configurations.annotationProcessor.get())
}
}

springBoot {
buildInfo()
}

repositories {
mavenCentral()
}

dependencies {
//region spring
annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")
implementation("org.springframework:spring-context-indexer")
implementation("org.springframework.boot:spring-boot-starter-data-r2dbc")
implementation("org.springframework.boot:spring-boot-starter-webflux")
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("org.springframework:spring-context-indexer")
annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")
implementation("org.springframework.boot:spring-boot-starter-validation")
//endregion
//region logback
implementation("ch.qos.logback.contrib:logback-jackson:0.1.5")
implementation("ch.qos.logback.contrib:logback-json-classic:0.1.5")
//endregion
//region lombok
annotationProcessor("org.projectlombok:lombok")
implementation("org.projectlombok:lombok")
//endregion
//region postgres
implementation("io.r2dbc:r2dbc-postgresql:0.8.13.RELEASE")
//endregion
}

object JVMProps {
const val XMX = "512m"
const val XMS = "256m"
const val XSS = "256k"
const val MAX_METASPACE_SIZE = "128m"
const val MAX_DIRECT_MEMORY_SIZE = "128m"
const val HEAPDUMP_PATH = "/opt/tmp/heapdump.bin"
const val MAX_RAM_PERCENTAGE = "80"
const val INITIAL_RAM_PERCENTAGE = "50"
}

jib {
to {
image = "sr-service:latest"
}
from {
image = "gcr.io/distroless/java21-debian12:latest"
}
container {
jvmFlags = listOf(
"-Xss${JVMProps.XSS}",
"-Xmx${JVMProps.XMX}",
"-Xms${JVMProps.XMS}",
"-XX:MaxMetaspaceSize=${JVMProps.MAX_METASPACE_SIZE}",
"-XX:MaxDirectMemorySize=${JVMProps.MAX_DIRECT_MEMORY_SIZE}",
"-XX:MaxRAMPercentage=${JVMProps.MAX_RAM_PERCENTAGE}",
"-XX:InitialRAMPercentage=${JVMProps.INITIAL_RAM_PERCENTAGE}",
"-XX:+HeapDumpOnOutOfMemoryError",
"-XX:HeapDumpPath=${JVMProps.HEAPDUMP_PATH}",
"-XX:+UseContainerSupport",
"-XX:+OptimizeStringConcat",
"-XX:+UseStringDeduplication",
"-XX:+ExitOnOutOfMemoryError",
"-XX:+AlwaysActAsServerClassMachine")
ports = listOf("8080")
labels.set(mapOf("appname" to application.applicationName, "version" to version.toString(), "maintainer" to "Vadzim Kavalkou <vadzim.kavalkou@gmail.com>"))
creationTime.set("USE_CURRENT_TIMESTAMP")
}
}

0 comments on commit 069a8db

Please sign in to comment.