mirror of
https://github.com/jeecgboot/JeecgBoot.git
synced 2026-07-30 01:46:02 +00:00
数据库初始化慢导致,微服务docker启动模式,gateway和前端无法访问实例接口(网关轮询nacos就绪再启动、暴露nacos控制台18080、前端nginx动态DNS解析)
This commit is contained in:
parent
56461aa3f4
commit
1cd59161a1
@ -48,6 +48,7 @@ services:
|
||||
context: ./jeecg-boot/jeecg-server-cloud/jeecg-cloud-nacos
|
||||
ports:
|
||||
- 8848:8848
|
||||
- 18080:18080
|
||||
container_name: jeecg-boot-nacos
|
||||
depends_on:
|
||||
- jeecg-boot-mysql
|
||||
@ -93,6 +94,19 @@ services:
|
||||
- jeecg-boot-system
|
||||
container_name: jeecg-boot-gateway
|
||||
hostname: jeecg-boot-gateway
|
||||
# 首次启动关键:主动轮询nacos,直到 jeecg-system 注册为健康实例再启动网关,
|
||||
# 避免网关先于system注册而拿到空路由(swagger空、前端调不到后台,需手动重启网关)
|
||||
# 注意:Nacos 3.x 已移除 v1/v2 open-api,实例查询需使用 v3 admin 接口
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- |
|
||||
echo 'waiting for jeecg-system to register in nacos...';
|
||||
until curl -s 'http://jeecg-boot-nacos:8848/nacos/v3/admin/ns/instance/list?serviceName=jeecg-system&groupName=DEFAULT_GROUP' | grep -q '"healthy":true'; do
|
||||
sleep 5;
|
||||
done;
|
||||
echo 'jeecg-system is registered, starting gateway.';
|
||||
exec java -Djava.security.egd=file:/dev/./urandom -jar jeecg-cloud-gateway-3.9.3.jar
|
||||
networks:
|
||||
- jeecg-boot
|
||||
|
||||
|
||||
@ -4,8 +4,12 @@ VOLUME /tmp
|
||||
ENV LANG en_US.UTF-8
|
||||
RUN echo "server { \
|
||||
listen 80; \
|
||||
#使用docker内嵌DNS运行时解析,避免gateway容器重启换IP后nginx缓存旧IP导致502 \
|
||||
resolver 127.0.0.11 valid=10s ipv6=off; \
|
||||
location /jeecgboot/ { \
|
||||
proxy_pass http://jeecg-boot-gateway:9999/; \
|
||||
set \$jeecg_gateway jeecg-boot-gateway; \
|
||||
rewrite ^/jeecgboot/?(.*)\$ /\$1 break; \
|
||||
proxy_pass http://\$jeecg_gateway:9999; \
|
||||
proxy_redirect off; \
|
||||
proxy_set_header Host jeecg-boot-system; \
|
||||
proxy_set_header X-Real-IP \$remote_addr; \
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user