Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 07d66ac666 | |||
| 42d2b5bf1c | |||
| d7c2a9cfad | |||
| 8da99d6861 | |||
| 6f20c662eb | |||
| 48d6b642e0 |
56
source_clean/deploy.sh
Executable file
56
source_clean/deploy.sh
Executable file
@@ -0,0 +1,56 @@
|
|||||||
|
#!/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 密码
|
||||||
|
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_URL="redis://CloudSearch_Redis:6379"
|
||||||
|
PROFILE="--profile full"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 生成 .env
|
||||||
|
cat > .env <<EOF
|
||||||
|
REDIS_URL=${REDIS_URL}
|
||||||
|
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
|
||||||
42
source_clean/docker-compose.yml
Normal file
42
source_clean/docker-compose.yml
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
name: cloudsearch
|
||||||
|
services:
|
||||||
|
app:
|
||||||
|
image: gitea.timxx.cn/admin/cloudsearch:v0.4.0
|
||||||
|
container_name: CloudSearch_App
|
||||||
|
restart: unless-stopped
|
||||||
|
ports: ["9527:9527"]
|
||||||
|
environment:
|
||||||
|
REDIS_URL: ${REDIS_URL}
|
||||||
|
PANSOU_URL: http://pansou:8888
|
||||||
|
CORS_ORIGIN: ${CORS_ORIGIN:-https://zy.hk.timxx.cn}
|
||||||
|
JWT_SECRET: ${JWT_SECRET:-cloudsearch-jwt-secret-2024}
|
||||||
|
ADMIN_PASSWORD: ${ADMIN_PASSWORD:-0nL5kLhMIJ1121PYmQb25A}
|
||||||
|
LOG_LEVEL: ${LOG_LEVEL:-info}
|
||||||
|
volumes: ["cloudsearch-data:/app/data"]
|
||||||
|
depends_on: [pansou]
|
||||||
|
networks: [cloudsearch-net]
|
||||||
|
|
||||||
|
pansou:
|
||||||
|
image: ghcr.io/fish2018/pansou-web:latest
|
||||||
|
container_name: CloudSearch_PanSou
|
||||||
|
restart: unless-stopped
|
||||||
|
networks:
|
||||||
|
cloudsearch-net: { aliases: [pansou] }
|
||||||
|
|
||||||
|
# Redis — 仅当系统没有现成 Redis 时才启动
|
||||||
|
redis:
|
||||||
|
image: redis:7-alpine
|
||||||
|
container_name: CloudSearch_Redis
|
||||||
|
restart: unless-stopped
|
||||||
|
command: redis-server --appendonly yes --maxmemory 256mb --maxmemory-policy allkeys-lru
|
||||||
|
volumes: ["redis-data:/data"]
|
||||||
|
networks: [cloudsearch-net]
|
||||||
|
profiles: [full]
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
cloudsearch-data:
|
||||||
|
redis-data:
|
||||||
|
|
||||||
|
networks:
|
||||||
|
cloudsearch-net:
|
||||||
|
driver: bridge
|
||||||
@@ -19,13 +19,6 @@ export function getDb(): Database.Database {
|
|||||||
db.pragma('journal_mode = WAL');
|
db.pragma('journal_mode = WAL');
|
||||||
db.pragma('foreign_keys = ON');
|
db.pragma('foreign_keys = ON');
|
||||||
|
|
||||||
// Performance indexes (IF NOT EXISTS ensures idempotent)
|
|
||||||
db.exec(`
|
|
||||||
CREATE INDEX IF NOT EXISTS idx_cc_type_active ON cloud_configs(cloud_type, is_active);
|
|
||||||
CREATE INDEX IF NOT EXISTS idx_cc_uid ON cloud_configs(cookie_uid);
|
|
||||||
CREATE INDEX IF NOT EXISTS idx_cc_verification ON cloud_configs(verification_status);
|
|
||||||
`);
|
|
||||||
|
|
||||||
runMigrations(db);
|
runMigrations(db);
|
||||||
seedAdmin(db);
|
seedAdmin(db);
|
||||||
|
|
||||||
@@ -131,6 +124,14 @@ function runMigrations(db: Database.Database): void {
|
|||||||
migrateSaveRecords(db);
|
migrateSaveRecords(db);
|
||||||
migrateContentCache(db);
|
migrateContentCache(db);
|
||||||
migrateCloudConfigs(db);
|
migrateCloudConfigs(db);
|
||||||
|
|
||||||
|
// Performance indexes on cloud_configs (after all columns exist)
|
||||||
|
db.exec(`
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_cc_type_active ON cloud_configs(cloud_type, is_active);
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_cc_uid ON cloud_configs(cookie_uid);
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_cc_verification ON cloud_configs(verification_status);
|
||||||
|
`);
|
||||||
|
|
||||||
cleanupOldSaveRecords(db);
|
cleanupOldSaveRecords(db);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user