20250423 jenkinsfile脚本调试 -3
Some checks failed
gitea-Liang/pipeline/head There was a failure building this commit
Some checks failed
gitea-Liang/pipeline/head There was a failure building this commit
This commit is contained in:
parent
bbd8e9a05c
commit
ea26255604
17
Jenkinsfile
vendored
17
Jenkinsfile
vendored
@ -12,12 +12,19 @@ pipeline {
|
||||
sh 'echo test'
|
||||
}
|
||||
}
|
||||
stage('Deploy') {
|
||||
stage('Build Docker Image') {
|
||||
steps {
|
||||
sh 'echo publish'
|
||||
sh 'echo "当前目录路径: $(pwd)"'
|
||||
sh 'liang-springcloud-alibaba-goods-service/target'
|
||||
sh 'cp ~/liang-springcloud-alibaba-goods-service-1.0-SNAPSHOT.jar /opt/service'
|
||||
// 构建 Docker 镜像
|
||||
sh 'docker build -t liang-springcloud-alibaba-goods-service:1.0-SNAPSHOT .'
|
||||
}
|
||||
}
|
||||
stage('Run Docker Container') {
|
||||
steps {
|
||||
// 停止并删除旧的容器(如果存在)
|
||||
sh 'docker stop liang-springcloud-alibaba-goods-service || true'
|
||||
sh 'docker rm liang-springcloud-alibaba-goods-service || true'
|
||||
// 运行新的 Docker 容器
|
||||
sh 'docker run -d -p 7002:7002 --name liang-springcloud-alibaba-goods-service liang-springcloud-alibaba-goods-service:1.0-SNAPSHOT'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
14
dockerfile
Normal file
14
dockerfile
Normal file
@ -0,0 +1,14 @@
|
||||
# 使用基础的 Java 镜像
|
||||
FROM openjdk:8-jdk-slim
|
||||
|
||||
# 设置工作目录
|
||||
WORKDIR /app
|
||||
|
||||
# 复制打包好的 JAR 文件到容器中
|
||||
COPY target/liang-springcloud-alibaba-goods-service-1.0-SNAPSHOT.jar app.jar
|
||||
|
||||
# 暴露应用端口,根据实际情况修改
|
||||
EXPOSE 7002
|
||||
|
||||
# 启动 Spring Boot 应用
|
||||
ENTRYPOINT ["java", "-jar", "app.jar"]
|
Loading…
Reference in New Issue
Block a user