empower_front/Scripts/docker-entrypoint.sh

25 lines
578 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/sh
set -e
# 目標檔案
ENV_FILE=/usr/share/nginx/html/env.js
# 確保目錄存在
mkdir -p /usr/share/nginx/html
# 寫入環境變數
cat <<EOF > "$ENV_FILE"
window.env = {
VITE_API_BASEURL: "${VITE_API_BASEURL:-http://localhost:8080}",
VITE_FILE_API_BASEURL: "${VITE_FILE_API_BASEURL:-http://localhost:8081}",
VITE_MQTT_BASEURL: "${VITE_MQTT_BASEURL:-ws://localhost:1883}",
VITE_APP_TITLE: "${VITE_APP_TITLE:-MyApp}"
};
EOF
echo "[Entrypoint] Generated $ENV_FILE:"
cat "$ENV_FILE"
# 執行傳入的 CMD例如 "nginx -g 'daemon off;'"
exec "$@"