Added config server

This commit is contained in:
Jim Martens 2023-08-14 23:41:15 +02:00
parent 35a3ca542e
commit 2711a94bfc
8 changed files with 121 additions and 1 deletions

View File

@ -38,6 +38,8 @@ spring-boot-oauth2-resource-server = { module = "org.springframework.boot:spring
spring-boot-config = { module = "org.springframework.boot:spring-boot-configuration-processor", version.ref = "spring-boot" }
spring-cloud = { module = "org.springframework.cloud:spring-cloud-dependencies", version.ref = "spring-cloud" }
spring-cloud-starter = { module = "org.springframework.cloud:spring-cloud-starter" }
spring-cloud-starter-config = { module = "org.springframework.cloud:spring-cloud-starter-config" }
spring-cloud-config-server = { module = "org.springframework.cloud:spring-cloud-config-server" }
spring-boot-starter = { module = "org.springframework.boot:spring-boot-starter" }
spring-grpc = { module = "net.devh:grpc-spring-boot-starter", version.ref = "spring-grpc" }
spring-ui = { module = "org.springdoc:springdoc-openapi-starter-webmvc-ui", version.ref = "spring-doc" }
@ -109,7 +111,6 @@ spring-boot = [
spring-boot-server = [
"spring-boot-actuator",
"spring-boot-log4j",
"spring-boot-mongo",
"spring-boot-thymeleaf",
"spring-boot-validation",
"spring-boot-web",

View File

@ -2,4 +2,8 @@ plugins {
id("twomartens.spring-boot-cloud")
id("twomartens.kotlin")
kotlin("kapt")
}
dependencies {
implementation(libs.spring.cloud.config.server)
}

View File

@ -0,0 +1,13 @@
package de.twomartens.configserver
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import org.springframework.cloud.config.server.EnableConfigServer
@SpringBootApplication
@EnableConfigServer
open class MainApplication
fun main(args: Array<String>) {
runApplication<MainApplication>(*args)
}

View File

@ -0,0 +1,36 @@
server:
port: 8888
shutdown: graceful
management:
# for security, don't use same port as application
server.port: 13000
health:
livenessState.enabled: true
readinessState.enabled: true
config.enabled: false
endpoints.web.exposure.include: '*'
endpoint:
health:
show-details: always
probes.enabled: false
group:
readiness.include: readinessState,diskSpace
liveness.include: livenessState
spring:
main:
banner-mode: off
profiles:
default: dev
cloud:
config:
server:
git:
uri: "https://git.2martens.de/2martens/{application}"
search-paths: module-server/src/main/resources
force-pull: true
deleteUntrackedBranches: true
prefix: /config
application:
name: config-server

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<Configuration status="warn" monitorInterval="30">
<Appenders>
<Console name="console" target="SYSTEM_OUT">
<PatternLayout alwaysWriteExceptions="true"
pattern="%5p %d{HH:mm:ss.SSS} (%F:%L) %notEmpty{[%X{REQTYPE}] }%notEmpty{[%marker] }%K{event.end}%m%n%xEx{full}"/>
</Console>
<Console name="interceptor" target="SYSTEM_OUT">
<!-- <EcsLayout servicename="${env:spring_application_name}" includeOrigin="true" includeMarkers="true"/>-->
<PatternLayout alwaysWriteExceptions="true"
pattern="%5p %d{HH:mm:ss.SSS} (%F:%L) %notEmpty{[%K{REQTYPE}] }%notEmpty{[%X{REQTYPE}] }%K{network.direction} %K{http.request.method} %K{http.response.status_code} %K{url.full} (duration=%K{event.duration} request-size=%K{http.request.body.bytes} response-size=%K{http.response.body.bytes} trace-id=%notEmpty{%K{trace.id}}%notEmpty{%X{trace.id}})%n%xEx{full}"/>
</Console>
</Appenders>
<Loggers>
<Root level="WARN">
<AppenderRef ref="console"/>
</Root>
<Logger additivity="true" level="INFO" name="statusprobe"/>
<Logger additivity="true" level="DEBUG" name="de.twomartens.configserver"/>
</Loggers>
</Configuration>

View File

@ -0,0 +1,8 @@
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring4-4.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" lang="en">
<th:block th:insert="~{errorIncludes :: head}"/>
<body>
<th:block th:insert="~{errorIncludes :: mainText}"/>
<th:block th:insert="~{errorIncludes :: footer}"/>
</body>
</html>

View File

@ -0,0 +1,9 @@
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring4-4.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" lang="en">
<th:block th:insert="~{errorIncludes :: head}" />
<body>
<th:block th:insert="~{errorIncludes :: mainText}" />
<p>The requested URL <code th:text="${path}"></code> was not found on this server.</p>
<th:block th:insert="~{errorIncludes :: footer}" />
</body>
</html>

View File

@ -0,0 +1,28 @@
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring4-4.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" lang="en">
<head th:fragment="head">
<title>Error <th:block th:text="${status}"/> (<th:block th:text="${error}"/>)</title>
<style>
@media (prefers-color-scheme: dark) {
html{background:#000000;color:#ffffff;font:15px/22px arial,sans-serif}
}
@media (prefers-color-scheme: light) {
html{background:#ffffff;color:#000000;font:15px/22px arial,sans-serif}
}
body{margin:50px}
h1,footer{margin:20px 0}
p{margin:0}
code{font-family: monospace,monospace}
.foot{color:#777777;font-size:80%}
</style>
</head>
<body>
<th:block th:fragment="mainText">
<h1>Wahlrecht</h1>
<p>
<b th:text="${status}"></b> <th:block th:text="${error}" />
</p>
</th:block>
<footer class="foot" th:fragment="footer"><th:block th:text="${footerString}" /></footer>
</body>
</html>