mengff
11 months ago
4 changed files with 72 additions and 5 deletions
@ -0,0 +1,14 @@ |
|||
# FROM java:8 |
|||
FROM anapsix/alpine-java:8_server-jre_unlimited |
|||
# 将当前目录下的jar包复制到docker容器的/目录下 |
|||
COPY *.jar /app.jar |
|||
# 运行过程中创建一个xx.jar文件 |
|||
RUN touch /app.jar |
|||
|
|||
ENV TZ=Asia/Shanghai JAVA_OPTS="-Xms128m -Xmx256m -Djava.security.egd=file:/dev/./urandom" |
|||
ENV PARAMS="--spring.profiles.active=druid" |
|||
|
|||
# 声明服务运行在8080端口 |
|||
EXPOSE 8088 |
|||
# 指定docker容器启动时运行jar包 |
|||
ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -jar /app.jar $PARAMS" ] |
@ -0,0 +1,53 @@ |
|||
pipeline{ |
|||
agent any |
|||
environment { |
|||
IMAGE_NAME = "ruoyi-admin" |
|||
WS = "${WORKSPACE}" |
|||
} |
|||
|
|||
//定义流水线的加工流程 |
|||
stages { |
|||
//流水线的所有阶段 |
|||
stage('1.环境检查'){ |
|||
steps { |
|||
sh 'pwd && ls -alh' |
|||
sh 'printenv' |
|||
sh 'docker version' |
|||
sh 'java -version' |
|||
sh 'git --version' |
|||
} |
|||
} |
|||
|
|||
stage('2.编译'){ |
|||
agent { |
|||
docker { |
|||
image 'maven:3-alpine' |
|||
args '-v maven-repository:/root/.m2' |
|||
} |
|||
} |
|||
steps { |
|||
sh 'pwd && ls -alh' |
|||
sh 'mvn -v' |
|||
sh 'cd ${WS} && mvn clean package -s "/var/jenkins_home/appconfig/maven/settings.xml" -Dmaven.test.skip=true' |
|||
} |
|||
} |
|||
|
|||
stage('3.打包'){ |
|||
steps { |
|||
sh 'pwd && ls -alh' |
|||
sh 'echo ${WS}' |
|||
// sh 'mv ${WS}/${IMAGE_NAME}/target/*.jar ${WS}/${IMAGE_NAME}.jar && pwd && ls -alh && docker build -t ${IMAGE_NAME} .' |
|||
sh 'docker build -t ${IMAGE_NAME} -f Dockerfile ${WS}/${IMAGE_NAME}/target/' |
|||
} |
|||
} |
|||
|
|||
stage('4.部署'){ |
|||
// 删除容器和虚悬镜像 |
|||
steps { |
|||
sh 'pwd && ls -alh' |
|||
sh 'docker rm -f ${IMAGE_NAME} || true && docker rmi $(docker images -q -f dangling=true) || true' |
|||
sh 'docker run -d -p 8888:8080 --name ${IMAGE_NAME} -v /mydata/logs/${IMAGE_NAME}:/logs/${IMAGE_NAME} ${IMAGE_NAME}' |
|||
} |
|||
} |
|||
} |
|||
} |
Loading…
Reference in new issue