Files

23 lines
624 B
Bash
Raw Permalink Normal View History

2026-05-11 10:41:36 +08:00
#!/bin/sh
# 由 nginx 官方镜像的入口脚本自动执行(位于 /docker-entrypoint.d/
# 将 config.js 中的占位符替换为运行期环境变量
set -e
CONFIG_FILE=/usr/share/nginx/html/config.js
if [ ! -f "$CONFIG_FILE" ]; then
echo "[entrypoint] $CONFIG_FILE 不存在,跳过注入" >&2
exit 0
fi
if [ -z "${API_BASE_URL:-}" ]; then
echo "[entrypoint] 错误:必须设置 API_BASE_URL 环境变量" >&2
exit 1
fi
# 用 | 作分隔符,避免 URL 里的 / 干扰
sed -i "s|__API_BASE_URL__|${API_BASE_URL}|g" "$CONFIG_FILE"
echo "[entrypoint] 已注入 API_BASE_URL=${API_BASE_URL}"