2018-05-03 05:43:04 +00:00
|
|
|
pipeline {
|
|
|
|
options {
|
2018-06-19 23:53:18 +00:00
|
|
|
buildDiscarder(logRotator(numToKeepStr: '10'))
|
2018-05-03 05:43:04 +00:00
|
|
|
disableConcurrentBuilds()
|
|
|
|
}
|
|
|
|
agent any
|
|
|
|
environment {
|
2018-07-26 01:45:52 +00:00
|
|
|
IMAGE_NAME = "nginx-proxy-manager"
|
2018-07-30 06:51:43 +00:00
|
|
|
BASE_IMAGE_NAME = "jc21/nginx-proxy-manager-base"
|
2018-07-26 01:45:52 +00:00
|
|
|
TEMP_IMAGE_NAME = "nginx-proxy-manager-build_${BUILD_NUMBER}"
|
|
|
|
TEMP_IMAGE_NAME_ARM = "nginx-proxy-manager-arm-build_${BUILD_NUMBER}"
|
2018-07-30 06:44:50 +00:00
|
|
|
//TAG_VERSION = getPackageVersion()
|
|
|
|
TAG_VERSION = "preview"
|
2018-05-03 06:07:34 +00:00
|
|
|
}
|
2018-05-03 05:43:04 +00:00
|
|
|
stages {
|
|
|
|
stage('Prepare') {
|
2018-06-20 00:31:10 +00:00
|
|
|
steps {
|
|
|
|
sh 'docker pull $DOCKER_CI_TOOLS'
|
2018-05-03 05:43:04 +00:00
|
|
|
}
|
|
|
|
}
|
2018-07-30 06:47:28 +00:00
|
|
|
stage('Build') {
|
|
|
|
parallel {
|
|
|
|
stage('x86_64') {
|
|
|
|
steps {
|
|
|
|
ansiColor('xterm') {
|
|
|
|
// Codebase
|
2018-07-30 06:51:43 +00:00
|
|
|
sh 'docker run --rm -v $(pwd):/srv/app -w /srv/app $BASE_IMAGE_NAME:latest yarn --registry=$NPM_REGISTRY install'
|
2018-07-31 03:48:35 +00:00
|
|
|
sh 'docker run --rm -v $(pwd):/srv/app -w /srv/app $BASE_IMAGE_NAME:latest npm run-script build'
|
2018-07-30 06:47:28 +00:00
|
|
|
sh 'rm -rf node_modules'
|
2018-07-30 06:51:43 +00:00
|
|
|
sh 'docker run --rm -v $(pwd):/srv/app -w /srv/app $BASE_IMAGE_NAME:latest yarn --registry=$NPM_REGISTRY install --prod'
|
2018-07-30 06:47:28 +00:00
|
|
|
sh 'docker run --rm -v $(pwd):/data $DOCKER_CI_TOOLS node-prune'
|
2018-07-26 01:45:52 +00:00
|
|
|
|
2018-07-30 06:47:28 +00:00
|
|
|
// Docker Build
|
|
|
|
sh 'docker build --pull --no-cache --squash --compress -t $TEMP_IMAGE_NAME .'
|
2018-05-03 05:43:04 +00:00
|
|
|
|
2018-07-30 06:47:28 +00:00
|
|
|
// Private Registry
|
|
|
|
sh 'docker tag $TEMP_IMAGE_NAME $DOCKER_PRIVATE_REGISTRY/$IMAGE_NAME:$TAG_VERSION'
|
|
|
|
sh 'docker push $DOCKER_PRIVATE_REGISTRY/$IMAGE_NAME:$TAG_VERSION'
|
2018-07-26 01:45:52 +00:00
|
|
|
|
2018-07-30 06:47:28 +00:00
|
|
|
// Dockerhub
|
|
|
|
sh 'docker tag $TEMP_IMAGE_NAME docker.io/jc21/$IMAGE_NAME:$TAG_VERSION'
|
2018-07-26 01:45:52 +00:00
|
|
|
|
2018-07-30 06:47:28 +00:00
|
|
|
withCredentials([usernamePassword(credentialsId: 'jc21-dockerhub', passwordVariable: 'dpass', usernameVariable: 'duser')]) {
|
|
|
|
sh "docker login -u '${duser}' -p '$dpass'"
|
|
|
|
sh 'docker push docker.io/jc21/$IMAGE_NAME:$TAG_VERSION'
|
2018-07-30 06:44:50 +00:00
|
|
|
}
|
2018-07-30 06:47:28 +00:00
|
|
|
|
|
|
|
sh 'docker rmi $TEMP_IMAGE_NAME'
|
2018-07-30 06:44:50 +00:00
|
|
|
}
|
|
|
|
}
|
2018-07-30 06:47:28 +00:00
|
|
|
}
|
|
|
|
stage('armhf') {
|
|
|
|
agent {
|
|
|
|
label 'armhf'
|
|
|
|
}
|
|
|
|
steps {
|
|
|
|
ansiColor('xterm') {
|
|
|
|
// Codebase
|
2018-07-30 06:51:43 +00:00
|
|
|
sh 'docker run --rm -v $(pwd):/srv/app -w /srv/app $BASE_IMAGE_NAME:armhf yarn --registry=$NPM_REGISTRY install'
|
2018-07-31 03:48:35 +00:00
|
|
|
sh 'docker run --rm -v $(pwd):/srv/app -w /srv/app $BASE_IMAGE_NAME:armhf npm run-script build'
|
2018-07-30 06:47:28 +00:00
|
|
|
sh 'rm -rf node_modules'
|
2018-07-30 06:51:43 +00:00
|
|
|
sh 'docker run --rm -v $(pwd):/srv/app -w /srv/app $BASE_IMAGE_NAME:armhf yarn --registry=$NPM_REGISTRY install --prod'
|
2018-07-24 22:40:21 +00:00
|
|
|
|
2018-07-30 06:47:28 +00:00
|
|
|
// Docker Build
|
2018-07-31 05:50:46 +00:00
|
|
|
sh 'docker build --pull --no-cache --squash --compress -t $TEMP_IMAGE_NAME_ARM -f Dockerfile.armhf .'
|
2018-07-30 06:44:50 +00:00
|
|
|
|
2018-07-30 06:47:28 +00:00
|
|
|
// Private Registry
|
2018-07-31 04:34:31 +00:00
|
|
|
sh 'docker tag $TEMP_IMAGE_NAME_ARM $DOCKER_PRIVATE_REGISTRY/$IMAGE_NAME:$TAG_VERSION-armhf'
|
2018-07-30 06:47:28 +00:00
|
|
|
sh 'docker push $DOCKER_PRIVATE_REGISTRY/$IMAGE_NAME:$TAG_VERSION-armhf'
|
2018-07-30 06:44:50 +00:00
|
|
|
|
2018-07-30 06:47:28 +00:00
|
|
|
// Dockerhub
|
2018-07-31 04:34:31 +00:00
|
|
|
sh 'docker tag $TEMP_IMAGE_NAME_ARM docker.io/jc21/$IMAGE_NAME:$TAG_VERSION-armhf'
|
2018-07-30 06:44:50 +00:00
|
|
|
|
2018-07-30 06:47:28 +00:00
|
|
|
withCredentials([usernamePassword(credentialsId: 'jc21-dockerhub', passwordVariable: 'dpass', usernameVariable: 'duser')]) {
|
|
|
|
sh "docker login -u '${duser}' -p '$dpass'"
|
|
|
|
sh 'docker push docker.io/jc21/$IMAGE_NAME:$TAG_VERSION-armhf'
|
2018-07-30 06:44:50 +00:00
|
|
|
}
|
2018-07-30 06:47:28 +00:00
|
|
|
|
2018-07-31 04:34:31 +00:00
|
|
|
sh 'docker rmi $TEMP_IMAGE_NAME_ARM'
|
2018-07-30 06:44:50 +00:00
|
|
|
}
|
|
|
|
}
|
2018-07-24 22:40:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-05-03 05:43:04 +00:00
|
|
|
}
|
|
|
|
post {
|
|
|
|
success {
|
2018-06-19 23:53:18 +00:00
|
|
|
juxtapose event: 'success'
|
2018-05-17 23:33:41 +00:00
|
|
|
sh 'figlet "SUCCESS"'
|
2018-05-03 05:43:04 +00:00
|
|
|
}
|
|
|
|
failure {
|
2018-06-19 23:53:18 +00:00
|
|
|
juxtapose event: 'failure'
|
2018-05-17 23:33:41 +00:00
|
|
|
sh 'figlet "FAILURE"'
|
2018-05-03 05:43:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-05-03 05:56:35 +00:00
|
|
|
|
|
|
|
def getPackageVersion() {
|
2018-06-19 23:53:18 +00:00
|
|
|
ver = sh(script: 'docker run --rm -v $(pwd):/data $DOCKER_CI_TOOLS bash -c "cat /data/package.json|jq -r \'.version\'"', returnStdout: true)
|
2018-05-03 05:56:35 +00:00
|
|
|
return ver.trim()
|
|
|
|
}
|