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;