-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### What's done: * Common gradle task for spring configuration * Wrapped deployment commands in gradle tasks
- Loading branch information
Showing
9 changed files
with
73 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
buildSrc/src/main/kotlin/org/cqfn/save/buildutils/DockerStackConfiguration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.cqfn.save.buildutils | ||
|
||
import org.gradle.api.Project | ||
import org.gradle.api.tasks.Exec | ||
import org.gradle.kotlin.dsl.register | ||
import org.gradle.kotlin.dsl.withType | ||
import org.springframework.boot.gradle.tasks.bundling.BootBuildImage | ||
|
||
fun Project.createStackDeployTask() { | ||
tasks.register<Exec>("startLocalDockerRegistry") { | ||
description = "Start local docker registry for spring boot images" | ||
commandLine("docker", "service", "create", "--name", "registry", "--publish", "published=6000,target=5000", "registry:2") | ||
} | ||
|
||
tasks.register<Exec>("deployDockerStack") { | ||
dependsOn(subprojects.flatMap { it.tasks.withType<BootBuildImage>() }) | ||
doFirst { | ||
copy { | ||
description = "Copy configuration files from repo to actual locations" | ||
from("save-deploy") | ||
into("${System.getProperty("user.home")}/configs") | ||
} | ||
} | ||
description = "Deploy docker stack to docker swarm" | ||
commandLine("docker", "stack", "deploy", "--compose-file", "docker-compose.yaml", "save") | ||
doLast { | ||
exec { | ||
description = "Stop local docker registry" | ||
commandLine("docker", "service", "rm", "registry") | ||
} | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
buildSrc/src/main/kotlin/org/cqfn/save/buildutils/SpringBootConfiguration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package org.cqfn.save.buildutils | ||
|
||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.apply | ||
import org.gradle.kotlin.dsl.dependencies | ||
import org.gradle.kotlin.dsl.named | ||
import org.springframework.boot.gradle.plugin.SpringBootPlugin | ||
import org.springframework.boot.gradle.tasks.bundling.BootBuildImage | ||
|
||
fun Project.configureSpringBoot() { | ||
apply<SpringBootPlugin>() | ||
|
||
dependencies { | ||
add("implementation", "org.springframework.boot:spring-boot-starter-webflux:${Versions.springBoot}") | ||
add("implementation", "org.springframework.boot:spring-boot-starter-actuator:${Versions.springBoot}") | ||
add("implementation", "io.micrometer:micrometer-registry-prometheus:${Versions.micrometer}") // expose prometheus metrics in actuator | ||
add("implementation", "org.springframework.security:spring-security-core:${Versions.springSecurity}") | ||
add("testImplementation", "org.springframework.boot:spring-boot-starter-test:${Versions.springBoot}") | ||
} | ||
|
||
tasks.named<BootBuildImage>("bootBuildImage") { | ||
dependsOn("startLocalDockerRegistry") | ||
docker { | ||
publishRegistry { | ||
host = "http://localhost:6000" | ||
} | ||
} | ||
isPublish = true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters