diff --git a/source_clean/deploy.sh b/source_clean/deploy.sh index 6d31c4b..309c85b 100755 --- a/source_clean/deploy.sh +++ b/source_clean/deploy.sh @@ -22,17 +22,25 @@ if [ -n "$EXISTING_REDIS" ]; then docker network connect cloudsearch-net "$EXISTING_REDIS" 2>/dev/null || true echo " ✅ 已加入 cloudsearch-net" fi - REDIS_HOST="$EXISTING_REDIS" + + # 检测 Redis 密码 + REDIS_PASS=$(docker inspect "$EXISTING_REDIS" --format '{{range .Config.Cmd}}{{println .}}{{end}}' 2>/dev/null | grep -A1 'requirepass' | tail -1 || true) + if [ -n "$REDIS_PASS" ]; then + REDIS_URL="redis://:${REDIS_PASS}@${EXISTING_REDIS}:6379" + echo " 🔑 检测到 Redis 密码,已自动配置" + else + REDIS_URL="redis://${EXISTING_REDIS}:6379" + fi PROFILE="" else echo "📦 未检测到 Redis,将自动创建..." - REDIS_HOST="CloudSearch_Redis" + REDIS_URL="redis://CloudSearch_Redis:6379" PROFILE="--profile full" fi # 生成 .env cat > .env <