From 13ade2e0013dc51fa69f05e4ced7e83a21b2de2a Mon Sep 17 00:00:00 2001 From: cat_shark <1716967236@qq.com> Date: Sun, 27 Jul 2025 19:29:51 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E5=8A=A0=E5=85=A5=E5=81=A5?= =?UTF-8?q?=E5=BA=B7=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 4 ++++ Jenkinsfile | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/Dockerfile b/Dockerfile index 0f0dcf4..d73c8c8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,7 @@ FROM nginx:alpine + +# 安装 curl 用于健康检查 +RUN apk add --no-cache curl + COPY dist/ /usr/share/nginx/html/ EXPOSE 80 diff --git a/Jenkinsfile b/Jenkinsfile index 9080bd1..54b0df9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -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 + ''' + } + } + } }