From d0a9aec12a694f188d8188a24ae461fd01020265 Mon Sep 17 00:00:00 2001 From: ko1234 Date: Thu, 21 Aug 2025 17:26:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20Dockerfile=20=E5=92=8C=20d?= =?UTF-8?q?ocker-entrypoint.sh=EF=BC=8C=E5=8B=95=E6=85=8B=E6=9B=BF?= =?UTF-8?q?=E6=8F=9B=20index.html=20=E7=9A=84=E6=A8=99=E9=A1=8C=E8=88=87?= =?UTF-8?q?=20favicon=EF=BC=8C=E6=94=B9=E5=96=84=E7=A4=BE=E7=BE=A4?= =?UTF-8?q?=E7=88=AC=E8=9F=B2=E6=8A=93=E5=8F=96=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 4 ++-- docker-entrypoint.sh | 2 ++ index.html | 14 +------------- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/Dockerfile b/Dockerfile index d42c142..d99ad28 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,8 +33,8 @@ COPY --from=builder /app/dist /usr/share/nginx/html # 暴露 Nginx 預設的 80 端口 EXPOSE 80 -# 2025-08-20 -LABEL changelog="2025-08-20: 動態設定網頁標題與 favicon與logo與預設build_img,標題由 VITE_APP_TITLE 環境變數控制,favicon、logo、build_img.jpg 由 VITE_FILE_API_BASEURL 動態插入,docker-entrypoint.sh 寫入 env.js 供前端讀取。" +# 2025-08-21 +LABEL changelog="2025-08-21: index.html 的 及 favicon 由 docker-entrypoint.sh 啟動時根據環境變數直接替換,社群爬蟲可正確抓取,env.js 仍供前端 JS 讀取其他動態參數。" # Nginx 已經預設啟動,所以不需要 CMD 指令 COPY docker-entrypoint.sh /docker-entrypoint.sh diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index aef6486..d85cfb1 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -1,3 +1,5 @@ #!/bin/sh echo "window.env = { VITE_API_BASEURL: '${VITE_API_BASEURL}', VITE_FILE_API_BASEURL: '${VITE_FILE_API_BASEURL}', VITE_MQTT_BASEURL: '${VITE_MQTT_BASEURL}', VITE_APP_TITLE: '${VITE_APP_TITLE}' };" > /usr/share/nginx/html/env.js +sed -i "s|<title>.*|${VITE_APP_TITLE}|g" /usr/share/nginx/html/index.html +sed -i "s| Cvilux EMS - +