diff --git a/auth-center/auth-center-bootstrap/build.gradle.kts b/auth-center/auth-center-bootstrap/build.gradle.kts index b57c041b..a7bc7012 100644 --- a/auth-center/auth-center-bootstrap/build.gradle.kts +++ b/auth-center/auth-center-bootstrap/build.gradle.kts @@ -1,18 +1,25 @@ @file:Suppress("UnstableApiUsage") +import com.palantir.gradle.gitversion.VersionDetails +import groovy.lang.Closure import org.springframework.boot.gradle.tasks.bundling.BootJar import org.springframework.boot.gradle.tasks.run.BootRun +import java.time.LocalDateTime description = "Muscle and Fitness Server :: Auth Center - Bootstrap" -tasks.withType { - this.enabled = true +plugins { + id("com.google.cloud.tools.jib") } springBoot { buildInfo() } +tasks.withType { + this.enabled = true +} + tasks.withType { if (project.hasProperty("jvmArgs")) { val jvmArgsProperty = (project.properties["jvmArgs"] as String) @@ -37,3 +44,28 @@ dependencies { implementation(project(":auth-center-web")) implementation(project(":auth-center-message")) } + +// https://github.com/GoogleContainerTools/jib/tree/master/jib-gradle-plugin +jib { + pluginExtensions { + pluginExtension { + implementation = "com.google.cloud.tools.jib.gradle.extension.springboot.JibSpringBootExtension" + properties = mapOf("useDeprecatedExcludeDevtoolsOption" to "true") + } + } + val temurinTag: String by properties + from.image = "eclipse-temurin:${temurinTag}" + val dockerHubRepositoryPrefix: String by properties + val projectArtifactId: String by properties + val authCenterArtifactId: String by properties + to.image = "$dockerHubRepositoryPrefix$projectArtifactId.$authCenterArtifactId" + val versionDetails: Closure by extra + val details = versionDetails() + to.tags = setOf("${details.gitHash}-${project.version}") + container.appRoot = "/$authCenterArtifactId" + val projectBuildSourceEncoding: String by properties + container.jvmFlags = listOf("-Dfile.encoding=$projectBuildSourceEncoding") + val authCenterPort: String by properties + container.ports = listOf(authCenterPort) + container.creationTime = LocalDateTime.now().toString() +} diff --git a/build.gradle.kts b/build.gradle.kts index 7718701b..2e9df2e3 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -13,6 +13,9 @@ plugins { id("org.springframework.boot") apply false // https://docs.spring.io/dependency-management-plugin/docs/current/reference/html/ id("io.spring.dependency-management") apply false + id("com.google.cloud.tools.jib") apply false + id("com.palantir.git-version") + id("com.github.ben-manes.versions") } java.sourceCompatibility = VERSION_17 @@ -26,6 +29,13 @@ tasks.withType { this.enabled = false } +buildscript { + dependencies { + // https://github.com/GoogleContainerTools/jib-extensions/blob/master/first-party/jib-spring-boot-extension-gradle/README.md + classpath("com.google.cloud.tools:jib-spring-boot-extension-gradle:0.1.0") + } +} + allprojects { val projectGroupId: String by project group = projectGroupId @@ -56,6 +66,8 @@ subprojects { plugin("org.springframework.boot") // https://docs.spring.io/dependency-management-plugin/docs/current/reference/html/ plugin("io.spring.dependency-management") + plugin("com.palantir.git-version") + plugin("com.github.ben-manes.versions") } tasks.withType { diff --git a/gradle.properties b/gradle.properties index 42a1d630..9c149466 100644 --- a/gradle.properties +++ b/gradle.properties @@ -23,6 +23,12 @@ kotlinVersion=1.6.21 springBootVersion=2.7.2 springCloudVersion=2021.0.3 springDependencyManagementVersion=1.0.12.RELEASE +jibVersion=3.2.1 +# Don't use alpine or slim version, https://hub.docker.com/_/eclipse-temurin?tab=tags&page=1&name=17.0.3_7-jre +temurinTag=17.0.3_7-jre +gradleGitVersion=0.15.0 +gradleVersionsPluginVersion=0.42.0 +dockerHubRepositoryPrefix=docker.io/ijohnnymiller/ springBootAdminStarterVersion=2.7.1 springDocVersion=1.6.9 logstashLogbackEncoderVersion=7.2 diff --git a/settings.gradle.kts b/settings.gradle.kts index a8f89110..cab02c87 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -4,11 +4,17 @@ pluginManagement { val kotlinVersion: String by settings val springBootVersion: String by settings val springDependencyManagementVersion: String by settings + val jibVersion: String by settings + val gradleGitVersion: String by settings + val gradleVersionsPluginVersion: String by settings plugins { kotlin("jvm") version kotlinVersion kotlin("plugin.spring") version kotlinVersion id("org.springframework.boot") version springBootVersion id("io.spring.dependency-management") version springDependencyManagementVersion + id("com.google.cloud.tools.jib") version jibVersion + id("com.palantir.git-version") version gradleGitVersion + id("com.github.ben-manes.versions") version gradleVersionsPluginVersion } }