From e2f357e4afad20ea68fabe6c2398c5b3374a4c1a Mon Sep 17 00:00:00 2001 From: dingzhaojun Date: Mon, 8 Jan 2024 06:31:25 +0800 Subject: [PATCH] consul update --- compose-traefik.yml | 7 ++++++- readme.txt | 2 +- src/main/resources/application.yml | 11 ++++++++--- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/compose-traefik.yml b/compose-traefik.yml index 262ac31..f32e2f4 100644 --- a/compose-traefik.yml +++ b/compose-traefik.yml @@ -35,7 +35,7 @@ services: - "--api.insecure=true" - "--api.debug=false" - "--ping=true" - - "--log.level=INFO" + - "--log.level=DEBUG" - "--log.format=common" - "--accesslog=false" - "--entrypoints.web.address=:8081" @@ -53,6 +53,11 @@ services: - "--providers.file.watch=true" - "--providers.file.directory=/etc/traefik/dynamic" - "--providers.file.debugloggeneratedtemplate=true" + - "--providers.consulCatalog=true" + - "--providers.consulCatalog.endpoint.address=consul:8500" + - "--providers.consulCatalog.exposedByDefault=false" + - "--providers.consulCatalog.stale=false" + - "--providers.consulCatalog.prefix=traefik" healthcheck: test: ["CMD-SHELL", "wget -q --spider --proxy off localhost:8080/ping || exit 1"] interval: 5s diff --git a/readme.txt b/readme.txt index 6e44507..2430d9a 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ ./mvnw.cmd clean spring-boot:build-image -Pnative -Dmaven.test.skip=true #运行docker image -docker compose -f compose.yml up -d +docker compose -f compose-dev.yml up -d docker compose -f compose-demo01-jib.yml up -d docker compose -f compose-demo01-jvm.yml up -d diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 2220a48..b690265 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -33,8 +33,8 @@ spring: compatibility-verifier: enabled: false consul: - host: localhost - port: 8500 + host: ${CONSUL_HOST:consul} + port: ${CONSUL_PORT:8500} discovery: register-health-check: true healthCheckPath: ${server.servlet.context-path}/actuator/health @@ -43,7 +43,12 @@ spring: metrics: ${server.servlet.context-path}/actuator/prometheus springboot: true isv: risesoft - tags: test,y9 + tags: + - traefik.enable=true + - traefik.http.routers.demo01.rule=PathPrefix(`/users`,`/actuator`) + prefer-ip-address: true + instance-id: ${spring.application.name}:${spring.application.instance-id:${random.value}} + service-name: ${spring.application.name} datasource: driverClassName: com.mysql.cj.jdbc.Driver url: jdbc:mysql://localhost:3306/y9_public?serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&useUnicode=true&characterEncoding=utf-8&rewriteBatchedStatements=true&useCompression=true&useSSL=false&allowPublicKeyRetrieval=true