#!/bin/bash
set -e

echo ">>> 拉取最新代码..."
git pull

echo ">>> 构建镜像..."
docker build -t ddac-front .

echo ">>> 重启容器..."
docker rm -f ddac-front 2>/dev/null
docker run -d -p 80:80 --name ddac-front --restart unless-stopped ddac-front

echo ">>> 清理旧镜像..."
docker image prune -f

echo ">>> 部署完成！"
docker ps --filter name=ddac-front --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"
