fix(docker): 优化域名解析和 Nginx 配置

- 添加循环检查 jmalcloud 主机名解析的功能,确保域名可用再启动 Nginx
-从 Nginx 配置中移除不必要的 DNS 解析设置 (resolver 指令)
This commit is contained in:
jmal 2025-07-02 10:19:25 +08:00
parent bf64ee0eb6
commit 810ae5f48f
3 changed files with 10 additions and 4 deletions

View File

@ -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 "$@"

View File

@ -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;

View File

@ -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;