feat:加入健康检查

This commit is contained in:
2025-07-27 19:29:51 +08:00
parent 219b4921d2
commit 13ade2e001
2 changed files with 21 additions and 0 deletions
+4
View File
@@ -1,3 +1,7 @@
FROM nginx:alpine FROM nginx:alpine
# 安装 curl 用于健康检查
RUN apk add --no-cache curl
COPY dist/ /usr/share/nginx/html/ COPY dist/ /usr/share/nginx/html/
EXPOSE 80 EXPOSE 80
Vendored
+17
View File
@@ -57,5 +57,22 @@ pipeline {
''' '''
} }
} }
stage('Run Docker Container') {
agent any
steps {
sh '''
docker rm -f $CONTAINER_NAME || true
docker run -d --name $CONTAINER_NAME \\
-p $HOST_PORT:$CONTAINER_PORT \\
--health-cmd="curl -f http://localhost:$CONTAINER_PORT || exit 1" \\
--health-interval=10s \\
--health-timeout=5s \\
--health-retries=3 \\
$IMAGE_NAME
'''
}
}
} }
} }