l
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
编码猿
2025-09-09 10:15:43 +08:00
parent 38f5407b2f
commit d4d17be8d8

View File

@@ -11,11 +11,6 @@ steps:
path: /var/run/docker.sock
commands:
- |
# 定义应用相关的名称标识
# APP_NAME="node-app"
# CONTAINER_NAME="node-app-prod"
CURRENT_TAG="${DRONE_COMMIT_SHA:0:8}"
echo "开始清理残留资源..."
# 1. 停止并删除正在运行的旧容器
@@ -31,7 +26,7 @@ steps:
echo "清理旧镜像..."
docker images --filter "reference=node-app:*" --format "{{.ID}} {{.Tag}}" | \
while read -r image_id tag; do
if [ "$tag" != "$CURRENT_TAG" ] && [ "$tag" != "<none>" ]; then
if [ "$tag" != "${DRONE_COMMIT_SHA:0:8}" ] && [ "$tag" != "<none>" ]; then
echo "删除旧镜像: node-app:${tag} (ID: ${image_id})"
docker rmi -f ${image_id} || true
fi
@@ -104,3 +99,4 @@ trigger:
event:
- push
- pull_request