From 1cd59161a1a3dc7bcaaad54768d35081a49a823c Mon Sep 17 00:00:00 2001 From: JEECG <445654970@qq.com> Date: Thu, 9 Jul 2026 14:05:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=E6=85=A2=E5=AF=BC=E8=87=B4=EF=BC=8C=E5=BE=AE=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1docker=E5=90=AF=E5=8A=A8=E6=A8=A1=E5=BC=8F=EF=BC=8Cgat?= =?UTF-8?q?eway=E5=92=8C=E5=89=8D=E7=AB=AF=E6=97=A0=E6=B3=95=E8=AE=BF?= =?UTF-8?q?=E9=97=AE=E5=AE=9E=E4=BE=8B=E6=8E=A5=E5=8F=A3(=E7=BD=91?= =?UTF-8?q?=E5=85=B3=E8=BD=AE=E8=AF=A2nacos=E5=B0=B1=E7=BB=AA=E5=86=8D?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=E3=80=81=E6=9A=B4=E9=9C=B2nacos=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E5=8F=B018080=E3=80=81=E5=89=8D=E7=AB=AFnginx?= =?UTF-8?q?=E5=8A=A8=E6=80=81DNS=E8=A7=A3=E6=9E=90)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose-cloud.yml | 14 ++++++++++++++ jeecgboot-vue3/Dockerfile.cloud | 6 +++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/docker-compose-cloud.yml b/docker-compose-cloud.yml index c72aa62ab..72a05c17b 100644 --- a/docker-compose-cloud.yml +++ b/docker-compose-cloud.yml @@ -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 diff --git a/jeecgboot-vue3/Dockerfile.cloud b/jeecgboot-vue3/Dockerfile.cloud index 691de965f..5874e9bc6 100644 --- a/jeecgboot-vue3/Dockerfile.cloud +++ b/jeecgboot-vue3/Dockerfile.cloud @@ -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; \