This commit is contained in:
10
.drone.yml
10
.drone.yml
@@ -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
|
||||
@@ -103,4 +98,5 @@ trigger:
|
||||
- develop
|
||||
event:
|
||||
- push
|
||||
- pull_request
|
||||
- pull_request
|
||||
|
||||
Reference in New Issue
Block a user