diff --git a/Dockerfile b/Dockerfile index f6accfe..264bbab 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,15 @@ FROM alpine as build ARG VERSION -ENV ALPINE_SERIES 3.11 -ENV ALPINE_MIRROR https://uk.alpinelinux.org/alpine/v${ALPINE_SERIES} +ENV ALPINE_SERIES 3.12 +ENV ALPINE_MIRROR https://ftp.halifax.rwth-aachen.de/alpine/v${ALPINE_SERIES} ENV ALPINE_ARCH x86_64 WORKDIR /root RUN set -xo pipefail; apk add --no-cache curl gnupg &&\ curl -LO ${ALPINE_MIRROR}/releases/${ALPINE_ARCH}/alpine-minirootfs-${VERSION}-${ALPINE_ARCH}.tar.gz &&\ curl -LO ${ALPINE_MIRROR}/releases/${ALPINE_ARCH}/alpine-minirootfs-${VERSION}-${ALPINE_ARCH}.tar.gz.asc &&\ - gpg --recv 0482D84022F52DF1C4E7CD43293ACD0907D9495A &&\ + gpg --keyserver pool.sks-keyservers.net --recv 0482D84022F52DF1C4E7CD43293ACD0907D9495A &&\ gpg --verify alpine-minirootfs-${VERSION}-${ALPINE_ARCH}.tar.gz.asc alpine-minirootfs-${VERSION}-${ALPINE_ARCH}.tar.gz &&\ mkdir /dest &&\ tar -C /dest -xvzf alpine-minirootfs-${VERSION}-${ALPINE_ARCH}.tar.gz &&\ @@ -17,7 +17,8 @@ RUN set -xo pipefail; apk add --no-cache curl gnupg &&\ FROM scratch ARG VERSION -LABEL version.alpine=$VERSION +ARG DATE COPY --from=build /dest / +RUN apk add --no-cache ca-certificates curl CMD ["/bin/sh"] - +LABEL version.alpine=$VERSION build.date=$DATE diff --git a/Jenkinsfile b/Jenkinsfile index 1a9b41e..1f44a07 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,40 +1,79 @@ +version = "3.12.3" project = "alpine" repo = "zknt" -version = "3.11.7" 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: registry_credentials, url: "https://"+registry ]) { - echo 'Starting to build docker image' - script { - def customImage = docker.build(registry+'/'+repo+'/'+project, "--build-arg VERSION=$version .") - customImage.push(version) - customImage.push(version.split(/\./)[0,1].join('.')) - customImage.push(version.split(/\./)[0]) - customImage.push("latest") + 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("latest") + customImage.push("3.12") + 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] + ":latest" + sh "docker push " + io_registry_image.split(/\:/)[0] + ":latest" + sh "docker image tag " + registry+'/'+repo+'/'+project+':'+version + ' ' + io_registry_image.split(/\:/)[0] + ":3.12" + sh "docker push " + io_registry_image.split(/\:/)[0] + ":3.12" + } - registry_credentials = "3deeee3d-6fce-4430-98dd-9b4db56f43f7" - withDockerRegistry([ credentialsId: registry_credentials ]) { - def official_image = repo+'/'+project+':'+version.split(/\./)[0,1].join('.') - sh "docker image tag " + registry+'/'+repo+'/'+project+':'+version + ' ' + official_image - sh "docker image tag " + registry+'/'+repo+'/'+project+':'+version + ' ' + official_image.split(/\:/)[0] - sh "docker push " + official_image - sh "docker push " + official_image.split(/\:/)[0] + 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 image tag " + registry+'/'+repo+'/'+project+':'+version + ' ' + quay_image + sh "docker push " + quay_image + sh "docker image tag " + registry+'/'+repo+'/'+project+':'+version + ' ' + quay_image.split(/\:/)[0] + ":latest" + sh "docker push " + quay_image.split(/\:/)[0] + ":latest" + sh "docker image tag " + registry+'/'+repo+'/'+project+':'+version + ' ' + quay_image.split(/\:/)[0] + ":3.12" + sh "docker push " + quay_image.split(/\:/)[0] + ":3.12" + } } } } } } - } post { always { - emailext body: 'build finished', subject: '[jenkins] docker '+project+': ' + currentBuild.result, to: 'cg@zknt.org', from: 'sysadm@zknt.org', attachLog: true + sh """docker container prune -f""" + sh """docker image prune -f""" + sh """docker rmi -f \$(docker images -q $registry/$repo/$project:$version)""" + sh """for image in \$(grep FROM Dockerfile | cut -d ' ' -f 2 | grep -vi -e SCRATCH -e bootstrapped | uniq); do docker rmi -f \$(docker images -q \${image}); done""" + emailext body: 'build finished', subject: '[jenkins] docker '+project+'('+version+'): ' + currentBuild.result, to: 'cg@zknt.org', from: 'sysadm@zknt.org', attachLog: true } } + options { + buildDiscarder(BuildHistoryManager([ + [ + conditions: [ + BuildResult(matchFailure: true) + ], + matchAtMost: 4, + continueAfterMatch: false + ], + [ + conditions: [ + BuildResult(matchSuccess: true) + ], + matchAtMost: 4, + continueAfterMatch: false + ], + [ + conditions: [ + BuildResult(matchSuccess: true, matchFailure: true) + ], + actions: [DeleteBuild()] + ] + ])) + } } diff --git a/README.md b/README.md index f3f1543..d95a05d 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ stock alpine Basic Alpine base image, pulling Alpines minirootfs and extracting to `scratch`. -Builds both `edge` and latest release (currently `3.11`) in branches. +Builds both `edge` and latest release (currently `3.12`) in branches. Source repository: https://git.zknt.org/dockers/alpine diff --git a/build.yaml b/build.yaml new file mode 100644 index 0000000..613f41f --- /dev/null +++ b/build.yaml @@ -0,0 +1,5 @@ +version: 3.12.3 +project: alpine +additional_tags: + - latest + - 3.12