diff --git a/Dockerfile b/Dockerfile index dcb5541b..6da6bbbc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM jc21/node +FROM jc21/nginx-proxy-manager-base:latest MAINTAINER Jamie Curnow LABEL maintainer="Jamie Curnow " @@ -7,20 +7,7 @@ ENV SUPPRESS_NO_CONFIG_WARNING=1 ENV S6_FIX_ATTRS_HIDDEN=1 RUN echo "fs.file-max = 65535" > /etc/sysctl.conf -# Nginx, letsencrypt and other packages -RUN apt-get update \ - && apt-get install --no-install-recommends --no-install-suggests -y curl ca-certificates apt-transport-https \ - && apt-key adv --fetch-keys http://dl.yarnpkg.com/debian/pubkey.gpg \ - && apt-key adv --fetch-keys http://nginx.org/keys/nginx_signing.key \ - && echo "deb http://nginx.org/packages/mainline/debian/ jessie nginx" > /etc/apt/sources.list.d/nginx.list \ - && echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list \ - && echo "deb http://ftp.debian.org/debian jessie-backports main" > /etc/apt/sources.list.d/backports.list \ - && apt-get update \ - && apt-get install --no-install-recommends --no-install-suggests -y \ - gnupg openssl dirmngr apt-transport-https wget \ - inetutils-ping build-essential apache2-utils yarn nginx \ - && apt-get install --no-install-recommends --no-install-suggests -y certbot letsencrypt -t jessie-backports \ - && apt-get clean +# Nginx, Node and required packages should already be installed from the base image # root filesystem COPY rootfs / diff --git a/Dockerfile.armhf b/Dockerfile.armhf index 45be5b63..37358f96 100644 --- a/Dockerfile.armhf +++ b/Dockerfile.armhf @@ -1,24 +1,13 @@ -FROM jc21/node:armhf +FROM jc21/nginx-proxy-manager-base:armhf MAINTAINER Jamie Curnow LABEL maintainer="Jamie Curnow " -RUN [ "cross-build-start" ] - ENV SUPPRESS_NO_CONFIG_WARNING=1 ENV S6_FIX_ATTRS_HIDDEN=1 RUN echo "fs.file-max = 65535" > /etc/sysctl.conf -# Nginx, letsencrypt and other packages -RUN apt-get update \ - && apt-get install --no-install-recommends --no-install-suggests -y ca-certificates apt-transport-https \ - && echo "deb http://ftp.debian.org/debian jessie-backports main" > /etc/apt/sources.list.d/backports.list \ - && apt-get update \ - && apt-get install --no-install-recommends --no-install-suggests -y \ - gnupg openssl dirmngr apt-transport-https wget nginx-full \ - inetutils-ping build-essential apache2-utils \ - && apt-get install --no-install-recommends --no-install-suggests -y certbot letsencrypt -t jessie-backports \ - && apt-get clean +# Nginx, Node and required packages should already be installed from the base image # root filesystem COPY rootfs / @@ -34,8 +23,7 @@ ADD dist /srv/app/dist ADD node_modules /srv/app/node_modules ADD src/backend /srv/app/src/backend ADD package.json /srv/app/package.json - -RUN [ "cross-build-end" ] +ADD knexfile.js /srv/app/knexfile.js # Volumes VOLUME [ "/data", "/etc/letsencrypt" ] diff --git a/Jenkinsfile b/Jenkinsfile index 43bf21ff..dfed92b1 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -8,7 +8,8 @@ pipeline { IMAGE_NAME = "nginx-proxy-manager" TEMP_IMAGE_NAME = "nginx-proxy-manager-build_${BUILD_NUMBER}" TEMP_IMAGE_NAME_ARM = "nginx-proxy-manager-arm-build_${BUILD_NUMBER}" - TAG_VERSION = getPackageVersion() + //TAG_VERSION = getPackageVersion() + TAG_VERSION = "preview" } stages { stage('Prepare') { @@ -16,82 +17,72 @@ pipeline { sh 'docker pull $DOCKER_CI_TOOLS' } } - stage('Build x86_64') { - steps { - ansiColor('xterm') { - sh 'docker run --rm -v $(pwd):/srv/app -w /srv/app jc21/node:latest yarn --registry=$NPM_REGISTRY install' - sh 'docker run --rm -v $(pwd):/srv/app -w /srv/app jc21/node:latest npm runscript build' - sh 'rm -rf node_modules' - sh 'docker run --rm -v $(pwd):/srv/app -w /srv/app jc21/node yarn --registry=$NPM_REGISTRY install --prod' - sh 'docker run --rm -v $(pwd):/data $DOCKER_CI_TOOLS node-prune' - sh 'docker build --pull --no-cache --squash --compress -t $TEMP_IMAGE_NAME .' + stages { + stage('Build') { + parallel { + stage('x86_64') { + steps { + ansiColor('xterm') { + // Codebase + sh 'docker run --rm -v $(pwd):/srv/app -w /srv/app $IMAGE_NAME-base:latest yarn --registry=$NPM_REGISTRY install' + sh 'docker run --rm -v $(pwd):/srv/app -w /srv/app $IMAGE_NAME-base:latest npm runscript build' + sh 'rm -rf node_modules' + sh 'docker run --rm -v $(pwd):/srv/app -w /srv/app $IMAGE_NAME-base:latest yarn --registry=$NPM_REGISTRY install --prod' + sh 'docker run --rm -v $(pwd):/data $DOCKER_CI_TOOLS node-prune' + + // 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:$TAG_VERSION' + sh 'docker push $DOCKER_PRIVATE_REGISTRY/$IMAGE_NAME:$TAG_VERSION' + + // Dockerhub + 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:$TAG_VERSION' + } + + sh 'docker rmi $TEMP_IMAGE_NAME' + } + } + } + stage('armhf') { + agent { + label 'armhf' + } + steps { + ansiColor('xterm') { + // Codebase + sh 'docker run --rm -v $(pwd):/srv/app -w /srv/app $IMAGE_NAME-base:armhf yarn --registry=$NPM_REGISTRY install' + sh 'docker run --rm -v $(pwd):/srv/app -w /srv/app $IMAGE_NAME-base:armhf npm runscript build' + sh 'rm -rf node_modules' + sh 'docker run --rm -v $(pwd):/srv/app -w /srv/app $IMAGE_NAME-base:armhf yarn --registry=$NPM_REGISTRY install --prod' + + // Docker Build + sh 'docker build --pull --no-cache --squash --compress -t TEMP_IMAGE_NAME_ARM .' + + // Private Registry + 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:$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:$TAG_VERSION-armhf' + } + + sh 'docker rmi TEMP_IMAGE_NAME_ARM' + } + } + } } } } - //stage('Build armhf') { - // steps { - // ansiColor('xterm') { - // sh 'docker run --rm -v $(pwd):/srv/app -w /srv/app jc21/node:armhf yarn --registry=$NPM_REGISTRY install' - // sh 'docker run --rm -v $(pwd):/srv/app -w /srv/app jc21/node:armhf npm run-script build' - // sh 'rm -rf node_modules' - // sh 'docker run --rm -v $(pwd):/srv/app -w /srv/app jc21/node:armhf yarn --registry=$NPM_REGISTRY install --prod' - // sh 'docker run --rm -v $(pwd):/data $DOCKER_CI_TOOLS node-prune' - // sh 'docker build --pull --no-cache --squash --compress -t $TEMP_IMAGE_NAME_ARM -f Dockerfile.armhf .' - // } - // } - //} - stage('Publish Private') { - steps { - 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_ARM ${DOCKER_PRIVATE_REGISTRY}/$IMAGE_NAME:$TAG_VERSION-armhf' - sh 'docker push ${DOCKER_PRIVATE_REGISTRY}/$IMAGE_NAME:$TAG_VERSION-armhf' - } - } - stage('Publish Public') { - 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.io/jc21/$IMAGE_NAME:latest' - sh 'docker tag $TEMP_IMAGE_NAME docker.io/jc21/$IMAGE_NAME:$TAG_VERSION' - - //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' - sh 'docker push docker.io/jc21/$IMAGE_NAME:$TAG_VERSION' - - //sh 'docker push docker.io/jc21/$IMAGE_NAME:latest-armhf' - //sh 'docker push docker.io/jc21/$IMAGE_NAME:$TAG_VERSION-armhf' - } - } - } - stage('Publish Beta') { - when { - branch 'v2-rewrite' - } - steps { - sh 'docker tag $TEMP_IMAGE_NAME ${DOCKER_PRIVATE_REGISTRY}/$IMAGE_NAME:preview' - sh 'docker push ${DOCKER_PRIVATE_REGISTRY}/$IMAGE_NAME:preview' - sh 'docker tag $TEMP_IMAGE_NAME docker.io/jc21/$IMAGE_NAME:preview' - //sh 'docker tag $TEMP_IMAGE_NAME_ARM docker.io/jc21/$IMAGE_NAME:preview-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:preview' - //sh 'docker push docker.io/jc21/$IMAGE_NAME:preview-armhf' - } - } - } - } - triggers { - bitbucketPush() } post { success { @@ -102,10 +93,6 @@ pipeline { juxtapose event: 'failure' sh 'figlet "FAILURE"' } - always { - sh 'docker rmi $TEMP_IMAGE_NAME' - //sh 'docker rmi $TEMP_IMAGE_NAME_ARM' - } } }