awesome/start.sh
cheney a5c5d24083
All checks were successful
Build and Deploy / build (push) Successful in 12s
Build and Deploy / deploy (push) Successful in 26s
refactor: 彻底移除 docker compose,改用纯 docker 构建+重启部署
2026-09-01 10:27:11 +08:00

52 lines
1.3 KiB
Bash
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
# Awesome Index 重启脚本(使用已构建的镜像,纯 docker run无 compose
DEPLOY_PATH="$(cd "$(dirname "$0")" && pwd)"
cd "$DEPLOY_PATH"
# 检查 .env 文件
if [ ! -f .env ]; then
if [ -f .env.example ]; then
cp .env.example .env
echo "已从 .env.example 创建 .env请检查 SESSION_SECRET / ADMIN_INIT_PASSWORD / AI_INGEST_KEY"
else
echo "错误: 缺少 .env 文件"
exit 1
fi
fi
# 停止并删除旧容器
echo "停止旧容器..."
docker rm -f awesome-index 2>/dev/null || true
# 用新镜像启动容器
echo "启动 Awesome Index..."
docker run -d \
--name awesome-index \
--restart unless-stopped \
-p 3000:3000 \
-v "$DEPLOY_PATH/data:/app/data" \
--env-file .env \
awesome-index:latest
# 健康检查
echo "等待服务就绪..."
sleep 5
MAX_RETRIES=10
RETRY_COUNT=0
while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do
if curl -sf http://localhost:3000/healthz > /dev/null 2>&1; then
echo "✓ 服务已启动: http://localhost:3000"
echo ""
echo "管理后台: http://localhost:3000/admin"
exit 0
fi
RETRY_COUNT=$((RETRY_COUNT + 1))
sleep 2
done
echo "✗ 服务启动失败,请检查日志: docker logs awesome-index"
exit 1