fix(ci): 修复部署流水线配置

- 使用 Git commit hash 作为镜像标签
- 增加健康检查超时到 15 秒
- 添加镜像清理阶段(保留 7 天)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-19 19:09:06 +08:00
parent bc707179ce
commit ec157b06dc
Vendored
+8 -2
View File
@@ -1,7 +1,7 @@
pipeline { pipeline {
agent none agent none
environment { environment {
IMAGE_NAME = 'lpt-fe:0.0' IMAGE_NAME = "lpt-fe:${env.GIT_COMMIT?.take(8) ?: '0.0'}"
CONTAINER_NAME = 'LPT_FE' CONTAINER_NAME = 'LPT_FE'
CONTAINER_PORT = '80' CONTAINER_PORT = '80'
} }
@@ -34,7 +34,13 @@ pipeline {
stage('健康检查') { stage('健康检查') {
agent any agent any
steps { steps {
sh 'sleep 5 && docker exec $CONTAINER_NAME curl -f http://localhost:$CONTAINER_PORT/ || (docker logs $CONTAINER_NAME && exit 1)' sh 'sleep 15 && docker exec $CONTAINER_NAME curl -f http://localhost:$CONTAINER_PORT/ || (docker logs $CONTAINER_NAME && exit 1)'
}
}
stage('清理旧镜像') {
agent any
steps {
sh 'docker image prune -af --filter "until=168h" || true'
} }
} }
} }