traefik
This commit is contained in:
parent
a927389e03
commit
0ee60843f8
|
@ -1,9 +1,10 @@
|
|||
version: '3.9'
|
||||
name: demo01
|
||||
name: demo01-jib
|
||||
services:
|
||||
demo01-jib:
|
||||
image: svn.youshengyun.com:9923/demo01-jib:1.0
|
||||
container_name: demo01-jib
|
||||
hostname: demo01-jib
|
||||
restart: unless-stopped
|
||||
extra_hosts:
|
||||
- "host.docker.internal:host-gateway"
|
||||
|
@ -17,6 +18,11 @@ services:
|
|||
- "traefik.enable=true"
|
||||
- "traefik.http.routers.demo01-jib.entrypoints=web"
|
||||
- "traefik.http.routers.demo01-jib.rule=PathPrefix(`/demo01`)"
|
||||
- "traefik.http.services.demo01.loadbalancer.server.scheme=http"
|
||||
- "traefik.http.services.demo01.loadbalancer.server.port=7055"
|
||||
|
||||
- "traefik.http.routers.demo01-jib-ssl.entrypoints=web-ssl"
|
||||
- "traefik.http.routers.demo01-jib-ssl.rule=PathPrefix(`/demo01`)"
|
||||
|
||||
networks:
|
||||
y9-share-net:
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
version: '3.9'
|
||||
name: demo01
|
||||
name: demo01-jvm
|
||||
services:
|
||||
demo01-jvm:
|
||||
image: svn.youshengyun.com:9923/demo01-jvm:1.0
|
||||
container_name: demo01-jvm
|
||||
hostname: demo01-jvm
|
||||
restart: unless-stopped
|
||||
extra_hosts:
|
||||
- "host.docker.internal:host-gateway"
|
||||
|
@ -17,6 +18,8 @@ services:
|
|||
- "traefik.enable=true"
|
||||
- "traefik.http.routers.demo01-jvm.entrypoints=web"
|
||||
- "traefik.http.routers.demo01-jvm.rule=PathPrefix(`/demo01`)"
|
||||
- "traefik.http.services.demo01.loadbalancer.server.scheme=http"
|
||||
- "traefik.http.services.demo01.loadbalancer.server.port=7055"
|
||||
|
||||
networks:
|
||||
y9-share-net:
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
version: '3.9'
|
||||
name: demo01
|
||||
name: demo01-native
|
||||
services:
|
||||
demo01-native:
|
||||
image: svn.youshengyun.com:9924/demo01-native:1.0
|
||||
container_name: demo01-native
|
||||
hostname: demo01-native
|
||||
restart: unless-stopped
|
||||
extra_hosts:
|
||||
- "host.docker.internal:host-gateway"
|
||||
|
@ -17,6 +18,8 @@ services:
|
|||
- "traefik.enable=true"
|
||||
- "traefik.http.routers.demo01-native.entrypoints=web"
|
||||
- "traefik.http.routers.demo01-native.rule=PathPrefix(`/demo01`)"
|
||||
- "traefik.http.services.demo01.loadbalancer.server.scheme=http"
|
||||
- "traefik.http.services.demo01.loadbalancer.server.port=7055"
|
||||
|
||||
networks:
|
||||
y9-share-net:
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
version: '3.9'
|
||||
name: traefik
|
||||
services:
|
||||
traefik:
|
||||
image: traefik:latest
|
||||
container_name: traefik01
|
||||
hostname: traefik
|
||||
restart: unless-stopped
|
||||
extra_hosts:
|
||||
- "host.docker.internal:host-gateway"
|
||||
networks:
|
||||
- y9-share-net
|
||||
ports:
|
||||
- "8081:8081"
|
||||
- "8080:8080"
|
||||
- "443:443"
|
||||
volumes:
|
||||
# Allows Traefik can listen to the Docker events
|
||||
- "/var/run/docker.sock:/var/run/docker.sock"
|
||||
# Mount the directory containing the certs
|
||||
- "d:/docker-config/traefik/certs:/etc/certs/"
|
||||
# Mount the dynamic configuration
|
||||
- "d:/docker-config/traefik/dynamic/certs-traefik.yaml:/etc/traefik/dynamic/certs-traefik.yaml"
|
||||
command:
|
||||
- "--global.sendanonymoususage=false"
|
||||
- "--global.checknewversion=false"
|
||||
- "--api=true"
|
||||
- "--api.dashboard=true"
|
||||
- "--api.insecure=true"
|
||||
- "--api.debug=false"
|
||||
- "--ping=true"
|
||||
- "--log.level=INFO"
|
||||
- "--log.format=common"
|
||||
- "--accesslog=false"
|
||||
- "--entrypoints.web.address=:8081"
|
||||
- "--entrypoints.web-ssl.address=:443"
|
||||
- "--entrypoints.traefik.address=:8080"
|
||||
- "--providers.docker=true"
|
||||
- "--providers.docker.watch=true"
|
||||
- "--providers.docker.exposedbydefault=false"
|
||||
- "--providers.docker.endpoint=unix:///var/run/docker.sock"
|
||||
- "--providers.docker.useBindPortIP=false"
|
||||
- "--providers.docker.network=y9-share-net"
|
||||
- "--providers.file=true"
|
||||
- "--providers.file.watch=true"
|
||||
- "--providers.file.directory=/etc/traefik/dynamic"
|
||||
- "--providers.file.debugloggeneratedtemplate=true"
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "wget -q --spider --proxy off localhost:8080/ping || exit 1"]
|
||||
interval: 5s
|
||||
retries: 10
|
||||
logging:
|
||||
driver: "json-file"
|
||||
options:
|
||||
max-size: "1m"
|
||||
|
||||
networks:
|
||||
y9-share-net:
|
||||
external: true
|
90
compose.yml
90
compose.yml
|
@ -38,7 +38,7 @@ services:
|
|||
command: redis-server --requirepass "12345678"
|
||||
volumes:
|
||||
- d:/docker-data/redis:/data
|
||||
|
||||
|
||||
consul:
|
||||
image: docker.io/bitnami/consul:latest
|
||||
container_name: consul01
|
||||
|
@ -53,17 +53,87 @@ services:
|
|||
- CONSUL_ENABLE_UI=true
|
||||
- CONSUL_HTTP_PORT_NUMBER=8500
|
||||
ports:
|
||||
#- '8300:8300'
|
||||
#- '8301:8301'
|
||||
#- '8301:8301/udp'
|
||||
- '8300:8300'
|
||||
- '8301:8301'
|
||||
- '8301:8301/udp'
|
||||
- '8500:8500'
|
||||
#- '8600:8600'
|
||||
#- '8600:8600/udp'
|
||||
- '8600:8600'
|
||||
- '8600:8600/udp'
|
||||
volumes:
|
||||
- d:/docker-data/consul:/bitnami/consul
|
||||
|
||||
|
||||
elasticsearch:
|
||||
image: elasticsearch:8.10.2
|
||||
container_name: elastic01
|
||||
restart: always
|
||||
extra_hosts:
|
||||
- "host.docker.internal:host-gateway"
|
||||
networks:
|
||||
- y9-share-net
|
||||
ports:
|
||||
- '9200:9200'
|
||||
- '9300:9300'
|
||||
volumes:
|
||||
- d:/docker-data/es:/usr/share/elasticsearch/data
|
||||
environment:
|
||||
- discovery.type=single-node
|
||||
- xpack.security.enabled=false
|
||||
labels:
|
||||
org.springframework.boot.service-connection: elasticsearch
|
||||
|
||||
kafka:
|
||||
image: bitnami/kafka:latest
|
||||
container_name: kafka01
|
||||
restart: always
|
||||
extra_hosts:
|
||||
- "host.docker.internal:host-gateway"
|
||||
networks:
|
||||
- y9-share-net
|
||||
ports:
|
||||
- "9092:9092"
|
||||
- "9094:9094"
|
||||
environment:
|
||||
- KAFKA_CFG_NODE_ID=0
|
||||
- KAFKA_CFG_PROCESS_ROLES=controller,broker
|
||||
- KAFKA_CFG_LISTENERS=PLAINTEXT://:9092,CONTROLLER://:9093,EXTERNAL://0.0.0.0:9094
|
||||
- KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://kafka:9092,EXTERNAL://localhost:9094
|
||||
- KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=CONTROLLER:PLAINTEXT,EXTERNAL:PLAINTEXT,PLAINTEXT:PLAINTEXT
|
||||
- KAFKA_CFG_CONTROLLER_LISTENER_NAMES=CONTROLLER
|
||||
- KAFKA_CFG_CONTROLLER_QUORUM_VOTERS=0@kafka:9093
|
||||
volumes:
|
||||
- d:/docker-data/kafka:/bitnami/kafka
|
||||
|
||||
nacos:
|
||||
image: nacos/nacos-server:v2.2.3
|
||||
container_name: nacos01
|
||||
restart: always
|
||||
extra_hosts:
|
||||
- "host.docker.internal:host-gateway"
|
||||
networks:
|
||||
- y9-share-net
|
||||
ports:
|
||||
- "8848:8848"
|
||||
- "9848:9848"
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
- PREFER_HOST_MODE=hostname
|
||||
- MODE=standalone
|
||||
- SPRING_DATASOURCE_PLATFORM=mysql
|
||||
- MYSQL_SERVICE_HOST=db
|
||||
- MYSQL_SERVICE_DB_NAME=nacos
|
||||
- MYSQL_SERVICE_PORT=3306
|
||||
- MYSQL_SERVICE_USER=root
|
||||
- MYSQL_SERVICE_PASSWORD=12345678
|
||||
- MYSQL_SERVICE_DB_PARAM=characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true
|
||||
- NACOS_AUTH_ENABLE=true
|
||||
- NACOS_AUTH_IDENTITY_KEY=nacos
|
||||
- NACOS_AUTH_IDENTITY_VALUE=nacos
|
||||
- NACOS_AUTH_TOKEN=VGhpc0lzTXlDdXN0b21TZWNyZXRLZXkwMTIzNDU2Nzg=
|
||||
volumes:
|
||||
- d:/docker-data/nacos-logs:/home/nacos/logs
|
||||
|
||||
networks:
|
||||
y9-share-net:
|
||||
external: true
|
||||
|
||||
|
||||
external: true
|
|
@ -2,12 +2,6 @@
|
|||
./mvnw.cmd clean spring-boot:build-image -Dmaven.test.skip=true
|
||||
./mvnw.cmd clean spring-boot:build-image -Pnative -Dmaven.test.skip=true
|
||||
|
||||
docker image ls
|
||||
|
||||
docker run --name demo01-jib --net y9-share-net -ti -p 7055:7055 svn.youshengyun.com:9923/demo01-jib:1.0
|
||||
docker run --name demo01-jvm --net y9-share-net -ti -p 17055:7055 svn.youshengyun.com:9923/demo01-jvm:1.0
|
||||
docker run --name demo01-native --net y9-share-net -ti -p 27055:7055 svn.youshengyun.com:9923/demo01-native:1.0
|
||||
|
||||
docker compose -f compose-demo01-jib.yml up -d
|
||||
docker compose -f compose-demo01-jvm.yml up -d
|
||||
docker compose -f compose-demo01-native.yml up -d
|
||||
|
|
|
@ -25,13 +25,12 @@ public class UserController {
|
|||
@GetMapping({"", "/"})
|
||||
public List<String> hosts(HttpServletRequest request){
|
||||
List<String> list = new ArrayList<String>();
|
||||
list.add("request.getServerName()=" + request.getServerName());
|
||||
list.add("request.getLocalAddr() =" + request.getLocalAddr());
|
||||
list.add("request.getLocalAddr() =" + request.getLocalName());
|
||||
list.add("serverName=" + request.getServerName());
|
||||
list.add("localAddr=" + request.getLocalAddr());
|
||||
return list;
|
||||
}
|
||||
|
||||
@GetMapping({"/api/users"})
|
||||
@GetMapping({"/users"})
|
||||
public List<User> users(){
|
||||
return userRepository.findAll();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue