diff --git a/app-server/build.gradle.kts b/app-server/build.gradle.kts index d7bccba3..4187a71a 100644 --- a/app-server/build.gradle.kts +++ b/app-server/build.gradle.kts @@ -1,10 +1,11 @@ import com.github.gradle.node.npm.task.NpmTask plugins { - id("com.microsoft.azure.azurewebapp") version "1.7.1" - id("org.jetbrains.dokka") version "1.9.20" - id("com.github.gmazzo.buildconfig") version "5.3.5" - id("com.github.node-gradle.node") version "7.0.2" + alias(libs.plugins.spring.boot) + alias(libs.plugins.azurewebapp) + alias(libs.plugins.dokka) + alias(libs.plugins.buildconfig) + alias(libs.plugins.node.gradle) } dependencyManagement { @@ -30,8 +31,6 @@ dependencies { implementation(libs.azure.blob) implementation(libs.bundles.kafka) - developmentOnly(libs.spring.boot.devtools) - annotationProcessor(libs.spring.boot.config.processor) testImplementation(libs.bundles.testing.integration) @@ -78,6 +77,7 @@ testing { implementation(libs.spring.boot.starter.security.get().toString()) implementation(libs.kotlin.logging.get().toString()) + } } register("apiTest") { @@ -137,6 +137,26 @@ buildConfig { buildConfigField("DEPLOY_VERSION", provider { deployVersion }) } +tasks { + jar { + manifest { + attributes( + "Manifest-Version" to "1.0", + "Main-Class" to "org.hkurh.doky.DokyApplication", + "Implementation-Title" to "Doky", + "Implementation-Version" to deployVersion, + "Implementation-Vendor" to "hkurh-pets", + "Created-By" to "Kotlin Gradle", + "Built-By" to "Hanna Kurhuzenkava" + ) + } + } + + assemble { + dependsOn(jar) + } +} + node { download = true version = "20.12.2" diff --git a/app-server/src/main/resources/logback-spring.xml b/app-server/src/main/resources/logback-spring.xml new file mode 100644 index 00000000..ce3e08ae --- /dev/null +++ b/app-server/src/main/resources/logback-spring.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + UTC + + + + status + + + + + + mdc + + + + + + + + + + + + + diff --git a/build.gradle.kts b/build.gradle.kts index 4a42121e..41260ddb 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,12 +8,12 @@ allprojects { group = "org.hkurh" plugins { - kotlin("jvm") version "1.9.25" - kotlin("plugin.spring") version "1.9.25" - kotlin("plugin.jpa") version "1.9.25" apply false - id("org.springframework.boot") version "3.3.4" apply false - id("io.spring.dependency-management") version "1.1.6" - id("org.sonarqube") version "5.1.0.4882" + alias(libs.plugins.kotlin.jvm) + alias(libs.plugins.kotlin.plugin.spring) + alias(libs.plugins.kotlin.plugin.jpa) apply false + alias(libs.plugins.spring.boot) apply false + alias(libs.plugins.spring.dependency.management) + alias(libs.plugins.sonarqube) } dependencyManagement { @@ -33,7 +33,6 @@ subprojects { apply(plugin = "org.jetbrains.kotlin.jvm") apply(plugin = "org.jetbrains.kotlin.plugin.spring") apply(plugin = "org.jetbrains.kotlin.plugin.jpa") - apply(plugin = "org.springframework.boot") apply(plugin = "io.spring.dependency-management") java { @@ -44,7 +43,7 @@ subprojects { val libs = rootProject.extensions.getByType().named("libs") dependencies { - implementation(libs.findLibrary("kotlin.logging").get()) + implementation(libs.findBundle("logging").get()) testImplementation(libs.findBundle("testing.unit").get()) } } diff --git a/email-service/build.gradle.kts b/email-service/build.gradle.kts index c157e249..6f8a7782 100644 --- a/email-service/build.gradle.kts +++ b/email-service/build.gradle.kts @@ -22,8 +22,6 @@ dependencies { implementation(libs.bundles.kafka) implementation(libs.bundles.json) - developmentOnly(libs.spring.boot.devtools) - annotationProcessor(libs.spring.boot.config.processor) testImplementation(libs.bundles.testing.integration) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index a8211caf..8b9bcc5c 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -19,6 +19,13 @@ azure-blob = "12.25.3" httpclient = "4.5.13" rest-assured = "5.3.0" junit4 = "4.13.2" +logback-encoder = "8.0" +spring-dependency-management = "1.1.6" +sonarqube = "5.1.0.4882" +azurewebapp = "1.7.1" +dokka = "1.9.20" +buildconfig = "5.3.5" +node-gradle = "7.0.2" [libraries] spring-boot-bom = { group = "org.springframework.boot", name = "spring-boot-dependencies", version.ref = "spring-boot" } @@ -34,7 +41,6 @@ spring-boot-starter-security = { group = "org.springframework.boot", name = "spr spring-boot-starter-validation = { group = "org.springframework.boot", name = "spring-boot-starter-validation" } spring-boot-starter-test = { group = "org.springframework.boot", name = "spring-boot-starter-test" } spring-boot-config-processor = { group = "org.springframework.boot", name = "spring-boot-configuration-processor" } -spring-boot-devtools = { group = "org.springframework.boot", name = "spring-boot-devtools" } spring-kafka-production = { group = "org.springframework.kafka", name = "spring-kafka" } spring-kafka-test = { group = "org.springframework.kafka", name = "spring-kafka-test" } azure-appconfiguration-config-web = { group = "com.azure.spring", name = "spring-cloud-azure-appconfiguration-config-web" } @@ -66,8 +72,11 @@ azure-blob = { group = "com.azure", name = "azure-storage-blob", version.ref = " httpclient = { group = "org.apache.httpcomponents", name = "httpclient", version.ref = "httpclient" } rest-assured = { group = "io.rest-assured", name = "rest-assured", version.ref = "rest-assured" } junit4 = { group = "junit", name = "junit", version.ref = "junit4" } +logback-classic = { group = "ch.qos.logback", name = "logback-classic" } +logback-encoder = { group = "net.logstash.logback", name = "logstash-logback-encoder", version.ref = "logback-encoder" } [bundles] +logging = ["kotlin-logging", "logback-classic", "logback-encoder"] flyway = ["flyway-core", "flyway-sqlserver", "flyway-mysql"] database-connectors = ["sqlserver-connector", "mysql-connector"] testing-unit = ["junit-jupiter", "mockito-jupiter", "mockito-kotlin"] @@ -83,5 +92,12 @@ jwt = ["jjwt-api", "jjwt-impl", "jjwt-jackson"] [plugins] kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin-jvm" } +kotlin-plugin-spring = { id = "org.jetbrains.kotlin.plugin.spring", version.ref = "kotlin-jvm" } +kotlin-plugin-jpa = { id = "org.jetbrains.kotlin.plugin.jpa", version.ref = "kotlin-jvm" } spring-boot = { id = "org.springframework.boot", version.ref = "spring-boot" } - +spring-dependency-management = { id = "io.spring.dependency-management", version.ref = "spring-dependency-management" } +sonarqube = { id = "org.sonarqube", version.ref = "sonarqube" } +azurewebapp = { id = "com.microsoft.azure.azurewebapp", version.ref = "azurewebapp" } +dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" } +buildconfig = { id = "com.github.gmazzo.buildconfig", version.ref = "buildconfig" } +node-gradle = { id = "com.github.node-gradle.node", version.ref = "node-gradle" } diff --git a/teamcity/app-server.Dockerfile b/teamcity/app-server.Dockerfile index 599f1a32..3ebc2f5a 100644 --- a/teamcity/app-server.Dockerfile +++ b/teamcity/app-server.Dockerfile @@ -1,9 +1,19 @@ FROM openjdk:17 +COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init +ADD 'https://dtdg.co/latest-java-tracer' /dd_tracer/java/dd-java-agent.jar + +ARG DD_VERSION=1 + +ENV DD_SERVICE=app-server +ENV DD_ENV=prod +ENV DD_VERSION=$DD_VERSION + EXPOSE 8080 -ENV ENV_PROFILE=prod ARG JAR_FILE=app-server/build/libs/app-server.jar COPY ${JAR_FILE} app.jar -ENTRYPOINT ["java","-jar", "-Dspring.profiles.active=${ENV_PROFILE}", "/app.jar"] +ENTRYPOINT ["/app/datadog-init"] + +CMD ["java","-jar", "-Dspring.profiles.active=prod", "/app.jar"]