Files
CloudSearch/source_clean/deploy.sh

49 lines
1.4 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
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$SCRIPT_DIR"
# 如果 docker-compose.yml 不存在,自动下载
if [ ! -f docker-compose.yml ]; then
echo "📥 下载 docker-compose.yml..."
wget -q https://gitea.timxx.cn/admin/CloudSearch/raw/branch/master/source_clean/docker-compose.yml
fi
echo "🔍 检测 Redis..."
EXISTING_REDIS=$(docker ps --format '{{.Names}}' | grep -i redis | head -1)
if [ -n "$EXISTING_REDIS" ]; then
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
# 生成 .env
cat > .env <<EOF
REDIS_URL=redis://${REDIS_HOST}:6379
CORS_ORIGIN=https://zy.hk.timxx.cn
JWT_SECRET=cloudsearch-jwt-secret-2024
ADMIN_PASSWORD=0nL5kLhMIJ1121PYmQb25A
LOG_LEVEL=info
EOF
echo ""
echo "🚀 启动服务..."
docker compose $PROFILE up -d
echo ""
echo "✅ 部署完成"
docker compose ps