From cb449a8f5d6539ac2b66cafe5d906b4384c2fa27 Mon Sep 17 00:00:00 2001 From: Jamie Curnow Date: Sun, 29 Jul 2018 19:09:40 +1000 Subject: [PATCH] Armhf build attempt --- Dockerfile | 2 - Dockerfile.armhf | 29 ++++++++++++ Jenkinsfile | 117 +++++++++++++++++++++++++++++++---------------- 3 files changed, 106 insertions(+), 42 deletions(-) create mode 100644 Dockerfile.armhf diff --git a/Dockerfile b/Dockerfile index 6816e531..e9ecb9ba 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,8 +17,6 @@ RUN curl -L -o /tmp/s6-overlay-amd64.tar.gz "https://github.com/just-containers/ # App ENV NODE_ENV=production -#ADD LICENCE /srv/manager/LICENCE -#ADD README.md /srv/manager/README.md ADD manager/dist /srv/manager/dist ADD manager/node_modules /srv/manager/node_modules ADD manager/src/backend /srv/manager/src/backend diff --git a/Dockerfile.armhf b/Dockerfile.armhf new file mode 100644 index 00000000..ca32bb24 --- /dev/null +++ b/Dockerfile.armhf @@ -0,0 +1,29 @@ +FROM jc21/nginx-proxy-manager-base:armhf + +MAINTAINER Jamie Curnow +LABEL maintainer="Jamie Curnow " + +ENV SUPPRESS_NO_CONFIG_WARNING=1 +ENV S6_FIX_ATTRS_HIDDEN=1 +RUN echo "fs.file-max = 65535" > /etc/sysctl.conf + +# root filesystem +COPY rootfs / + +# s6 overlay +RUN curl -L -o /tmp/s6-overlay-armhf.tar.gz "https://github.com/just-containers/s6-overlay/releases/download/v1.21.4.0/s6-overlay-armhf.tar.gz" \ + && tar xzf /tmp/s6-overlay-armhf.tar.gz -C / + +# App +ENV NODE_ENV=production + +ADD manager/dist /srv/manager/dist +ADD manager/node_modules /srv/manager/node_modules +ADD manager/src/backend /srv/manager/src/backend +ADD manager/package.json /srv/manager/package.json + +# Volumes +VOLUME [ "/config", "/etc/letsencrypt" ] +CMD [ "/init" ] + +HEALTHCHECK --interval=15s --timeout=3s CMD curl -f http://localhost:9876/health || exit 1 diff --git a/Jenkinsfile b/Jenkinsfile index aa8381ef..7c0c8c36 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,54 +1,94 @@ pipeline { options { - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '10')) + buildDiscarder(logRotator(numToKeepStr: '10')) disableConcurrentBuilds() } agent any environment { - IMAGE_NAME = "nginx-proxy-manager" - TEMP_IMAGE_NAME = "nginx-proxy-manager-build_${BUILD_NUMBER}" - TAG_VERSION = getPackageVersion() + IMAGE_NAME = "nginx-proxy-manager" + TEMP_IMAGE_NAME = "nginx-proxy-manager-build_${BUILD_NUMBER}" + TEMP_IMAGE_NAME_ARM = "nginx-proxy-manager-armhf-build_${BUILD_NUMBER}" + TAG_VERSION = getPackageVersion() } stages { - stage('Prepare') { - steps { - sh 'docker pull jc21/$IMAGE_NAME-base' - sh 'docker pull $DOCKER_CI_TOOLS' - } - } stage('Build') { - steps { - sh 'docker run --rm -v $(pwd)/manager:/srv/manager -w /srv/manager jc21/$IMAGE_NAME-base yarn --registry=$NPM_REGISTRY install' - sh 'docker run --rm -v $(pwd)/manager:/srv/manager -w /srv/manager jc21/$IMAGE_NAME-base gulp build' - sh 'rm -rf node_modules' - sh 'docker run --rm -v $(pwd)/manager:/srv/manager -w /srv/manager jc21/$IMAGE_NAME-base yarn --registry=$NPM_REGISTRY install --prod' - sh 'docker run --rm -v $(pwd)/manager:/data $DOCKER_CI_TOOLS node-prune' - sh 'docker build --squash --compress -t $TEMP_IMAGE_NAME .' - } - } - stage('Publish') { - when { - branch 'master' - } - steps { - sh 'docker tag $TEMP_IMAGE_NAME ${DOCKER_PRIVATE_REGISTRY}/$IMAGE_NAME:latest' - sh 'docker push ${DOCKER_PRIVATE_REGISTRY}/$IMAGE_NAME:latest' - sh 'docker tag $TEMP_IMAGE_NAME ${DOCKER_PRIVATE_REGISTRY}/$IMAGE_NAME:$TAG_VERSION' - sh 'docker push ${DOCKER_PRIVATE_REGISTRY}/$IMAGE_NAME:$TAG_VERSION' - sh 'docker tag $TEMP_IMAGE_NAME docker.io/jc21/$IMAGE_NAME:latest' - sh 'docker tag $TEMP_IMAGE_NAME docker.io/jc21/$IMAGE_NAME:$TAG_VERSION' + parallel { + stage('x86_64') { + when { + branch 'master' + } + steps { + // Codebase + sh 'docker pull jc21/$IMAGE_NAME-base' + sh 'docker run --rm -v $(pwd)/manager:/srv/manager -w /srv/manager jc21/$IMAGE_NAME-base yarn --registry=$NPM_REGISTRY install' + sh 'docker run --rm -v $(pwd)/manager:/srv/manager -w /srv/manager jc21/$IMAGE_NAME-base gulp build' + sh 'rm -rf node_modules' + sh 'docker run --rm -v $(pwd)/manager:/srv/manager -w /srv/manager jc21/$IMAGE_NAME-base yarn --registry=$NPM_REGISTRY install --prod' + sh 'docker run --rm -v $(pwd)/manager:/data $DOCKER_CI_TOOLS node-prune' - withCredentials([usernamePassword(credentialsId: 'jc21-dockerhub', passwordVariable: 'dpass', usernameVariable: 'duser')]) { - sh "docker login -u '${duser}' -p '$dpass'" - sh 'docker push docker.io/jc21/$IMAGE_NAME:latest' - sh 'docker push docker.io/jc21/$IMAGE_NAME:$TAG_VERSION' + // Docker Build + sh 'docker build --pull --no-cache --squash --compress -t $TEMP_IMAGE_NAME .' + + // Private Registry + sh 'docker tag $TEMP_IMAGE_NAME $DOCKER_PRIVATE_REGISTRY/$IMAGE_NAME:latest' + sh 'docker push $DOCKER_PRIVATE_REGISTRY/$IMAGE_NAME:latest' + sh 'docker tag $TEMP_IMAGE_NAME ${DOCKER_PRIVATE_REGISTRY}/$IMAGE_NAME:$TAG_VERSION' + sh 'docker push ${DOCKER_PRIVATE_REGISTRY}/$IMAGE_NAME:$TAG_VERSION' + + // Dockerhub + sh 'docker tag $TEMP_IMAGE_NAME docker.io/jc21/$IMAGE_NAME:latest' + sh 'docker tag $TEMP_IMAGE_NAME docker.io/jc21/$IMAGE_NAME:$TAG_VERSION' + + withCredentials([usernamePassword(credentialsId: 'jc21-dockerhub', passwordVariable: 'dpass', usernameVariable: 'duser')]) { + sh "docker login -u '${duser}' -p '$dpass'" + sh 'docker push docker.io/jc21/$IMAGE_NAME:latest' + sh 'docker push docker.io/jc21/$IMAGE_NAME:$TAG_VERSION' + } + + sh 'docker rmi $TEMP_IMAGE_NAME' + } + } + stage('armhf') { + when { + branch 'master' + } + agent { + label 'armhf' + } + steps { + // Codebase + sh 'docker pull jc21/$IMAGE_NAME-base:armhf' + sh 'docker run --rm -v $(pwd)/manager:/srv/manager -w /srv/manager jc21/$IMAGE_NAME-base:armhf yarn --registry=$NPM_REGISTRY install' + sh 'docker run --rm -v $(pwd)/manager:/srv/manager -w /srv/manager jc21/$IMAGE_NAME-base:armhf gulp build' + sh 'rm -rf node_modules' + sh 'docker run --rm -v $(pwd)/manager:/srv/manager -w /srv/manager jc21/$IMAGE_NAME-base:armhf yarn --registry=$NPM_REGISTRY install --prod' + sh 'docker run --rm -v $(pwd)/manager:/data $DOCKER_CI_TOOLS:latest-armhf node-prune' + + // Docker Build + sh 'docker build --pull --no-cache --squash --compress -f Dockerfile.armhf -t $TEMP_IMAGE_NAME_ARM .' + + // Private Registry + sh 'docker tag $TEMP_IMAGE_NAME_ARM $DOCKER_PRIVATE_REGISTRY/$IMAGE_NAME:latest-armhf' + sh 'docker push $DOCKER_PRIVATE_REGISTRY/$IMAGE_NAME:latest-armhf' + sh 'docker tag $TEMP_IMAGE_NAME_ARM ${DOCKER_PRIVATE_REGISTRY}/$IMAGE_NAME:$TAG_VERSION-armhf' + sh 'docker push ${DOCKER_PRIVATE_REGISTRY}/$IMAGE_NAME:$TAG_VERSION-armhf' + + // Dockerhub + sh 'docker tag $TEMP_IMAGE_NAME_ARM docker.io/jc21/$IMAGE_NAME:latest-armhf' + sh 'docker tag $TEMP_IMAGE_NAME_ARM docker.io/jc21/$IMAGE_NAME:$TAG_VERSION-armhf' + + withCredentials([usernamePassword(credentialsId: 'jc21-dockerhub', passwordVariable: 'dpass', usernameVariable: 'duser')]) { + sh "docker login -u '${duser}' -p '$dpass'" + sh 'docker push docker.io/jc21/$IMAGE_NAME:latest-armhf' + sh 'docker push docker.io/jc21/$IMAGE_NAME:$TAG_VERSION-armhf' + } + + sh 'docker rmi $TEMP_IMAGE_NAME_ARM' + } } } } } - triggers { - bitbucketPush() - } post { success { slackSend color: "#72c900", message: "SUCCESS: <${BUILD_URL}|${JOB_NAME}> build #${BUILD_NUMBER} - ${currentBuild.durationString}" @@ -58,9 +98,6 @@ pipeline { slackSend color: "#d61111", message: "FAILED: <${BUILD_URL}|${JOB_NAME}> build #${BUILD_NUMBER} - ${currentBuild.durationString}" sh 'figlet "FAILURE"' } - always { - sh 'docker rmi $TEMP_IMAGE_NAME' - } } }