Files
CloudSearch/source_clean/deploy.sh

39 lines
1.2 KiB
Bash
Executable File
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/bash
set -e
echo "🔍 检测 Redis..."
# 查找当前 docker-compose 网络内或全局已运行的 Redis 容器
EXISTING_REDIS=$(docker ps --format '{{.Names}}' | grep -i redis | head -1)
if [ -n "$EXISTING_REDIS" ]; then
# 检查它是否已在 cloudsearch-net 网络中
if docker network inspect cloudsearch-net --format '{{range .Containers}}{{.Name}} {{end}}' 2>/dev/null | grep -qw "$EXISTING_REDIS"; then
echo "✅ 已有 Redis: $EXISTING_REDIS (已加入 cloudsearch-net),跳过创建"
else
echo "✅ 已有 Redis: $EXISTING_REDIS,正在加入网络..."
docker network connect cloudsearch-net "$EXISTING_REDIS" 2>/dev/null || true
echo " ✅ 已加入 cloudsearch-net"
fi
REDIS_HOST="$EXISTING_REDIS"
PROFILE=""
else
echo "📦 未检测到 Redis将自动创建..."
REDIS_HOST="CloudSearch_Redis"
PROFILE="--profile full"
fi
echo "REDIS_URL=redis://${REDIS_HOST}:6379" > .env
echo "CORS_ORIGIN=https://zy.hk.timxx.cn" >> .env
echo "JWT_SECRET=cloudsearch-jwt-secret-2024" >> .env
echo "ADMIN_PASSWORD=0nL5kLhMIJ1121PYmQb25A" >> .env
echo "LOG_LEVEL=info" >> .env
echo ""
echo "🚀 启动服务..."
docker compose $PROFILE up -d
echo ""
echo "✅ 部署完成"
docker compose ps