This repository has been archived on 2025-06-09. You can view files and clone it, but cannot push or open issues or pull requests.

42 lines
1.0 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
WIPE=false
if [ "$1" == "--wipe" ]; then
WIPE=true
fi
# 載入 .env 中的變數
if [ -f .env ]; then
export $(grep -v '^#' .env | xargs)
echo "📦 .env 載入完成"
else
echo "❌ 沒有找到 .env無法載入環境變數"
exit 1
fi
# 使用 .env 中的 APP_NAME 作為 project name
PROJECT_NAME="${APP_NAME}"
NETWORK_NAME="${APP_NAME}_network"
# 組合額外參數(如果有需要清除 volume 與 image
EXTRA_FLAGS=""
if [ "$WIPE" == "true" ]; then
EXTRA_FLAGS="-v --rmi all"
# 檢查並建立 network如果不存在
if ! docker network ls --format '{{.Name}}' | grep -wq "$NETWORK_NAME"; then
echo "🔌 Docker 網路 $NETWORK_NAME 不存在"
else
docker network rm $NETWORK_NAME
echo "🔌 Docker 網路 $NETWORK_NAME 已刪除"
fi
fi
echo "🛑 Stopping APP services..."
docker compose -p "$PROJECT_NAME" -f docker-compose.yml down $EXTRA_FLAGS
if [ "$WIPE" == "true" ]; then
echo "🧹 所有資料volumes, image已清除"
else
echo "✅ 所有服務 $PROJECT_NAME 已成功關閉。"
fi