From 810ae5f48f1e4ec7b8ca95b3ce90bf6526a7cb95 Mon Sep 17 00:00:00 2001 From: jmal Date: Wed, 2 Jul 2025 10:19:25 +0800 Subject: [PATCH] =?UTF-8?q?fix(docker):=20=E4=BC=98=E5=8C=96=E5=9F=9F?= =?UTF-8?q?=E5=90=8D=E8=A7=A3=E6=9E=90=E5=92=8C=20Nginx=20=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加循环检查 jmalcloud 主机名解析的功能,确保域名可用再启动 Nginx -从 Nginx 配置中移除不必要的 DNS 解析设置 (resolver 指令) --- docker-entrypoint.sh | 10 ++++++++++ nginx/nginx.conf.no_office.template | 2 -- nginx/nginx.conf.template | 2 -- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index b5e147d..3b21c93 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -11,4 +11,14 @@ else fi envsubst '${API_URL} ${API_OFFICE_URL}' < /var/www/public/config.js.template > /var/www/public/config.js + +# 循环检查,直到 jmalcloud 主机名可以被成功解析 +# 使用 getent hosts 是比 ping 更可靠的方式,因为它直接查询名称服务 +while ! getent hosts jmalcloud > /dev/null 2>&1; do + echo "jmalcloud is not yet resolvable, waiting 2 seconds..." + sleep 2 +done + +echo "jmalcloud is now resolvable. Starting Nginx..." + exec "$@" diff --git a/nginx/nginx.conf.no_office.template b/nginx/nginx.conf.no_office.template index 406310f..4d9fac8 100644 --- a/nginx/nginx.conf.no_office.template +++ b/nginx/nginx.conf.no_office.template @@ -16,8 +16,6 @@ http { include mime.types; default_type application/octet-stream; - resolver 127.0.0.11 valid=30s ipv6=off; - # 日志 #access_log /var/log/nginx/access.log main buffer=32k flush=5s; access_log off; diff --git a/nginx/nginx.conf.template b/nginx/nginx.conf.template index 6a53d5e..b319f91 100644 --- a/nginx/nginx.conf.template +++ b/nginx/nginx.conf.template @@ -16,8 +16,6 @@ http { include mime.types; default_type application/octet-stream; - resolver 127.0.0.11 valid=30s ipv6=off; - # 日志 #access_log /var/log/nginx/access.log main buffer=32k flush=5s; access_log off;