-
下载对应的maven
https://hub.docker.com/_/maven/tags?page=&page_size=&ordering=&name=3.5.3-alpinedocker pull maven:3.5.3-alpine@sha256:4c4e266aacf8ea6976b52df8467134b9f628cfed347c2f6aaf9e6aff832f7c45
2、下载对应的jdk
https://hub.docker.com/_/openjdk/tags?page=&page_size=&ordering=&name=8u332docker pull openjdk:8u332@sha256:a113091e38c3fa501056c435e8884dccc999569fa1be2b35be1cdee0502752c6
docker save -o 自定义名称.tar xxxx 下载的镜像
docker load -i 自定义名称.tar
docker tag xxxx:v1 xxxx:xxx:xxxx
3、jenkin打包 docker login 验证【通过jenkin构建的项目构建记录,找到回放】
steps {withCredentials([usernamePassword(credentialsId: 'harbor-xxx', passwordVariable: 'HPASSWD', usernameVariable: 'HUSER')]) {sh '''docker build --build-arg BASE_IMAGE=reg.xxx.com/library/arm64/openjdk:8u332-nc -f xxx/Dockerfile -t reg.xxx.com/dev/xx-arm64:1.0 .docker login reg.xxx.com -u $HUSER -p $HPASSWDdocker push reg.xxx.com/dev/xx-arm64:1.0'''}}
完整的JenkinFile
pipeline {agent {docker {image 'reg.xxx.com/library/arm64/maven-arm64:3.5.3'args '-v /root/.m2:/root/.m2 -v /usr/bin/docker:/usr/bin/docker -v /var/run/docker.sock:/var/run/docker.sock -v /usr/bin/kubectl:/usr/bin/kubectl'label 'arm64'}}stages {stage('build') {steps {sh 'mvn clean package -U -P ${active_profile}'}}stage('deploy') { steps {withCredentials([usernamePassword(credentialsId: 'harbor-xxx', passwordVariable: 'HPASSWD', usernameVariable: 'HUSER')]) {sh '''docker build --build-arg BASE_IMAGE=reg.xxx.com/library/arm64/openjdk:8u332-nc -f xxx/Dockerfile -t reg.xxx.com/dev/xx-arm64:1.0 .docker login reg.xxx.com -u $HUSER -p $HPASSWDdocker push reg.xxx.com/dev/xx-arm64:1.0'''}}}}
}
对应的DockerFile
ARG BASE_IMAGE
FROM ${BASE_IMAGE}ADD target/xxx.jar /opt/xxx.jarWORKDIR /var/www/appEXPOSE 7999#环境变量 JAVA_OPTS DEBUG_OPTS JMX_OPTS SPRING_CONFIG 由k8s传入
ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS $DEBUG_OPTS $JMX_OPTS -jar /opt/xxx.jar --spring.config.location=$SPRING_CONFIG" ]