fix(deploy): 初始化并校验公开 API 地址
This commit is contained in:
Executable
+80
@@ -0,0 +1,80 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
TMP_DIR="$(mktemp -d)"
|
||||
trap 'rm -rf "$TMP_DIR"' EXIT
|
||||
|
||||
cp \
|
||||
"$REPO_ROOT/start.sh" \
|
||||
"$REPO_ROOT/docker-compose.yml" \
|
||||
"$REPO_ROOT/.env.sample" \
|
||||
"$REPO_ROOT/.env.tools.sample" \
|
||||
"$REPO_ROOT/.env.ASG.sample" \
|
||||
"$REPO_ROOT/.env.AMS.sample" \
|
||||
"$REPO_ROOT/easyai-proxy.conf.sample" \
|
||||
"$TMP_DIR/"
|
||||
mkdir -p "$TMP_DIR/scripts"
|
||||
cp \
|
||||
"$REPO_ROOT/scripts/init-security-env.sh" \
|
||||
"$REPO_ROOT/scripts/init-public-api-base-url.sh" \
|
||||
"$TMP_DIR/scripts/"
|
||||
|
||||
cd "$TMP_DIR"
|
||||
|
||||
reset_case() {
|
||||
rm -f \
|
||||
.env \
|
||||
.env.tools \
|
||||
.env.ASG \
|
||||
.env.AMS \
|
||||
demo.example.com.conf
|
||||
}
|
||||
|
||||
sed -i.bak 's/^SERVER_HTTP_PORT=.*/SERVER_HTTP_PORT=4100/' .env.sample
|
||||
rm -f .env.sample.bak
|
||||
DEPLOY_NON_INTERACTIVE=1 \
|
||||
DEPLOY_DRY_RUN=1 \
|
||||
DEPLOY_ACCESS=ip \
|
||||
DEPLOY_IP=10.0.0.8 \
|
||||
bash start.sh >/dev/null
|
||||
grep -qx 'NUXT_PUBLIC_BASE_APIURL=http://10.0.0.8:4100' .env
|
||||
grep -qx 'CONFIG_PUBLIC_API_BASE_URL=http://10.0.0.8:4100' .env
|
||||
if command -v docker >/dev/null 2>&1 && docker compose version >/dev/null 2>&1; then
|
||||
docker compose config --quiet
|
||||
fi
|
||||
|
||||
reset_case
|
||||
DEPLOY_NON_INTERACTIVE=1 \
|
||||
DEPLOY_DRY_RUN=1 \
|
||||
DEPLOY_ACCESS=domain \
|
||||
DEPLOY_DOMAIN=demo.example.com \
|
||||
DEPLOY_HTTPS=false \
|
||||
bash start.sh >/dev/null
|
||||
grep -qx 'NUXT_PUBLIC_BASE_SOCKETURL=ws://demo.example.com/socket.io' .env
|
||||
grep -qx 'CONFIG_PUBLIC_API_BASE_URL=http://demo.example.com/api' .env
|
||||
grep -q 'proxy_set_header X-Forwarded-Host $easyai_forwarded_host;' demo.example.com.conf
|
||||
grep -q 'proxy_set_header X-Forwarded-Port $server_port;' demo.example.com.conf
|
||||
grep -q "proxy_set_header X-Original-Prefix '/api';" demo.example.com.conf
|
||||
|
||||
reset_case
|
||||
DEPLOY_NON_INTERACTIVE=1 \
|
||||
DEPLOY_DRY_RUN=1 \
|
||||
DEPLOY_ACCESS=domain \
|
||||
DEPLOY_DOMAIN=demo.example.com \
|
||||
DEPLOY_HTTPS=true \
|
||||
bash start.sh >/dev/null
|
||||
grep -qx 'NUXT_PUBLIC_BASE_SOCKETURL=wss://demo.example.com/socket.io' .env
|
||||
grep -qx 'CONFIG_PUBLIC_API_BASE_URL=https://demo.example.com/api' .env
|
||||
|
||||
reset_case
|
||||
DEPLOY_NON_INTERACTIVE=1 \
|
||||
DEPLOY_DRY_RUN=1 \
|
||||
DEPLOY_ACCESS=ip \
|
||||
DEPLOY_IP=10.0.0.8 \
|
||||
DEPLOY_PUBLIC_API_BASE_URL=https://edge.example.com:8443/custom-api \
|
||||
bash start.sh >/dev/null
|
||||
grep -qx 'CONFIG_PUBLIC_API_BASE_URL=https://edge.example.com:8443/custom-api' .env
|
||||
|
||||
echo "Deployment public URL dry-run tests passed"
|
||||
Reference in New Issue
Block a user