fix: add Docker Compose V2 support for all management scripts

Add docker-compose-helper.sh to auto-detect and use:
- docker-compose (V1 - standalone)
- docker compose (V2 - plugin)

Update all 9 management scripts to use the helper:
- start.sh, stop.sh, restart.sh
- logs.sh, status.sh
- backup.sh, restore.sh, update.sh, cleanup.sh

This fixes "docker-compose: command not found" error on systems
with Docker Compose V2 installed.

Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
This commit is contained in:
2026-03-17 17:47:49 +08:00
parent 9ea9eb4b61
commit ea11288642
10 changed files with 78 additions and 16 deletions

View File

@@ -3,7 +3,12 @@
set -e
# 載入 docker compose 輔助函數
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/docker-compose-helper.sh"
echo "🚀 啟動 CodiMD 服務..."
echo " 使用: $DOCKER_COMPOSE_CMD"
# 檢查 .env 是否存在
if [ ! -f .env ]; then
@@ -23,7 +28,7 @@ if ! docker info > /dev/null 2>&1; then
fi
# 啟動服務
docker-compose up -d
docker_compose up -d
echo ""
echo "⏳ 等待服務啟動..."
@@ -32,7 +37,7 @@ sleep 5
# 顯示服務狀態
echo ""
echo "📊 服務狀態:"
docker-compose ps
docker_compose ps
echo ""
echo "✅ CodiMD 已啟動!"