diff --git a/Dockerfile b/Dockerfile index 2def035..531c9fb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,8 +13,8 @@ RUN set -xe;\ rm -rf /var/lib/apt/lists/* FROM bootstrapped as toolbuilder -ARG GOSU_VERSION -ARG DUMB_INIT_VERSION +ENV GOSU_VERSION="1.12" +ENV DUMB_INIT_VERSION="1.2.2" RUN set -xe;\ apt-get update &&\ apt-get install -y git golang &&\ @@ -33,8 +33,8 @@ RUN set -xe;\ FROM bootstrapped ARG DATE -ARG GOSU_VERSION -ARG DUMB_INIT_VERSION +ENV GOSU_VERSION="1.12" +ENV DUMB_INIT_VERSION="1.2.2" COPY --from=toolbuilder /build/build /usr/local/sbin/gosu COPY --from=toolbuilder /dumb-init /usr/local/sbin/dumb-init COPY apt-install /bin/apt-install diff --git a/Jenkinsfile b/Jenkinsfile index 0350818..564b80d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,37 +1,54 @@ -gosu_version = "1.12" -dumb_init_version = "1.2.2" +version = "10" +project = "debian" +repo = "zknt" +registry = "reg.zknt.org" +registry_credentials = "6ff44976-23cd-4cc2-902c-de8c340e65e5" timeStamp = Calendar.getInstance().getTime().format('YYYY-MM-dd',TimeZone.getTimeZone('UTC')) pipeline { agent any - stages { - stage('Build image') { - steps { - withDockerRegistry([ credentialsId: "6ff44976-23cd-4cc2-902c-de8c340e65e5", url: "https://reg.zknt.org" ]) { - script { - def customImage = docker.build("reg.zknt.org/zknt/debian", "--pull --build-arg DATE=$timeStamp --build-arg GOSU_VERSION=$gosu_version --build-arg DUMB_INIT_VERSION=$dumb_init_version --no-cache .") - customImage.push("buster") - customImage.push("stable") - customImage.push("10") + stages { + stage('Build image') { + steps { + withDockerRegistry([ credentialsId: registry_credentials, url: "https://"+registry ]) { + script { + def customImage = docker.build(registry+'/'+repo+'/'+project, "--pull --build-arg VERSION=$version --build-arg DATE=$timeStamp .") + customImage.push(version) + customImage.push("buster") + customImage.push("stable") + def io_registry_credentials = "3deeee3d-6fce-4430-98dd-9b4db56f43f7" + withDockerRegistry([ credentialsId: io_registry_credentials ]) { + def io_registry_image = repo + '/' + project + ':' + version + sh "docker image tag " + registry+'/'+repo+'/'+project+':'+version + ' ' + io_registry_image + sh "docker push " + io_registry_image + sh "docker image tag " + registry+'/'+repo+'/'+project+':'+version + ' ' + io_registry_image.split(/\:/)[0] + "buster" + sh "docker push " + io_registry_image.split(/\:/)[0] + "buster" + sh "docker image tag " + registry+'/'+repo+'/'+project+':'+version + ' ' + io_registry_image.split(/\:/)[0] + "stable" + sh "docker push " + io_registry_image.split(/\:/)[0] + "stable" + } - registry_credentials = "3deeee3d-6fce-4430-98dd-9b4db56f43f7" - withDockerRegistry([ credentialsId: registry_credentials ]) { - def official_image = 'zknt/debian:buster' - sh "docker image tag reg.zknt.org/zknt/debian:buster " + official_image - sh "docker push " + official_image + def quay_credentials= "18fb6f7e-c6bc-4d06-9bf9-08c2af6bfc1a" + withDockerRegistry([ credentialsId: quay_credentials, url: "https://quay.io" ]) { + def quay_image = 'quay.io/' + repo + '/' + project + ':' + version + sh "docker push " + quay_image + sh "docker image tag " + registry+'/'+repo+'/'+project+':'+version + ' ' + official_image.split(/\:/)[0] + "buster" + sh "docker push " + official_image.split(/\:/)[0] + "buster" + sh "docker image tag " + registry+'/'+repo+'/'+project+':'+version + ' ' + official_image.split(/\:/)[0] + "stable" + sh "docker push " + official_image.split(/\:/)[0] + "stable" + } } } } } } - } + post { success { sh """docker rmi -f \$(docker images -q $registry/$repo/$project:$version)""" sh """for image in \$(grep FROM Dockerfile | cut -d ' ' -f 2); do docker rmi -f \$(docker images -q \${image}); done""" } always { - emailext body: 'build finished', subject: '[jenkins] docker debian: ' + currentBuild.result, to: 'cg@zknt.org', from: 'sysadm@zknt.org', attachLog: true + emailext body: 'build finished', subject: '[jenkins] docker '+project+'('+version+'): ' + currentBuild.result, to: 'cg@zknt.org', from: 'sysadm@zknt.org', attachLog: true } } options { @@ -47,7 +64,7 @@ pipeline { conditions: [ BuildResult(matchSuccess: true) ], - matchAtMost: 2, + matchAtMost: 4, continueAfterMatch: false ], [ @@ -58,5 +75,4 @@ pipeline { ] ])) } - -} +} \ No newline at end of file diff --git a/build.yaml b/build.yaml new file mode 100644 index 0000000..b5d7ede --- /dev/null +++ b/build.yaml @@ -0,0 +1,5 @@ +version: 10 +project: debian +additional_tags: + - buster + - stable