Docker build changes

This commit is contained in:
Jamie Curnow 2018-06-20 09:53:18 +10:00
parent 4045caaf88
commit 3970d2891f
8 changed files with 37 additions and 25 deletions

View File

@ -1,4 +1,4 @@
FROM jc21/nginx-proxy-manager-base
FROM jc21/node
MAINTAINER Jamie Curnow <jc@jc21.com>
LABEL maintainer="Jamie Curnow <jc@jc21.com>"
@ -7,6 +7,19 @@ 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 \
&& 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 nginx-full \
inetutils-ping letsencrypt build-essential apache2-utils yarn \
&& apt-get install --no-install-recommends --no-install-suggests -y certbot -t jessie-backports \
&& apt-get clean
# root filesystem
COPY rootfs /
@ -17,15 +30,13 @@ 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
ADD manager/package.json /srv/manager/package.json
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
# Volumes
VOLUME [ "/config", "/etc/letsencrypt" ]
VOLUME [ "/data", "/etc/letsencrypt" ]
CMD [ "/init" ]
HEALTHCHECK --interval=15s --timeout=3s CMD curl -f http://localhost:9876/health || exit 1

17
Jenkinsfile vendored
View File

@ -1,6 +1,6 @@
pipeline {
options {
buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '10'))
buildDiscarder(logRotator(numToKeepStr: '10'))
disableConcurrentBuilds()
}
agent any
@ -13,16 +13,17 @@ pipeline {
stage('Prepare') {
steps {
sh 'docker pull jc21/$IMAGE_NAME-base'
sh 'docker pull jc21/node'
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 'docker run --rm -v $(pwd):/srv/app -w /srv/app jc21/node yarn --registry=$NPM_REGISTRY install'
sh 'docker run --rm -v $(pwd):/srv/app -w /srv/app jc21/node bin/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 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 --squash --compress -t $TEMP_IMAGE_NAME .'
}
}
@ -51,11 +52,11 @@ pipeline {
}
post {
success {
slackSend color: "#72c900", message: "SUCCESS: <${BUILD_URL}|${JOB_NAME}> build #${BUILD_NUMBER} - ${currentBuild.durationString}"
juxtapose event: 'success'
sh 'figlet "SUCCESS"'
}
failure {
slackSend color: "#d61111", message: "FAILED: <${BUILD_URL}|${JOB_NAME}> build #${BUILD_NUMBER} - ${currentBuild.durationString}"
juxtapose event: 'failure'
sh 'figlet "FAILURE"'
}
always {
@ -65,6 +66,6 @@ pipeline {
}
def getPackageVersion() {
ver = sh(script: 'docker run --rm -v $(pwd)/manager:/data $DOCKER_CI_TOOLS bash -c "cat /data/package.json|jq -r \'.version\'"', returnStdout: true)
ver = sh(script: 'docker run --rm -v $(pwd):/data $DOCKER_CI_TOOLS bash -c "cat /data/package.json|jq -r \'.version\'"', returnStdout: true)
return ver.trim()
}

View File

@ -4,7 +4,7 @@ server {
listen 9876 default;
server_name localhost;
access_log /config/logs/manager.log proxy;
access_log /data/logs/manager.log proxy;
set $server 127.0.0.1;
set $port 81;
@ -26,7 +26,7 @@ server {
listen 80 default;
server_name localhost;
access_log /config/logs/default.log proxy;
access_log /data/logs/default.log proxy;
include conf.d/include/assets.conf;
include conf.d/include/block-exploits.conf;

View File

@ -15,7 +15,7 @@ location ^~ /.well-known/acme-challenge/ {
# there to "webroot".
# Do NOT use alias, use root! Target directory is located here:
# /var/www/common/letsencrypt/.well-known/acme-challenge/
root /config/letsencrypt-acme-challenge;
root /data/letsencrypt-acme-challenge;
}
# Hide /acme-challenge subdirectory and return 404 on all requests.

View File

@ -1,6 +1,6 @@
#!/usr/bin/with-contenv bash
mkdir -p /config/letsencrypt-acme-challenge
mkdir -p /data/letsencrypt-acme-challenge
cd /srv/manager
node --abort_on_uncaught_exception --max_old_space_size=250 /srv/manager/src/backend/index.js
cd /srv/app
node --abort_on_uncaught_exception --max_old_space_size=250 /srv/app/src/backend/index.js

View File

@ -1,5 +1,5 @@
#!/usr/bin/with-contenv bash
mkdir -p /tmp/nginx /config/{nginx,logs,access} /config/nginx/stream /var/lib/nginx/cache/{public,private}
mkdir -p /tmp/nginx /data/{nginx,logs,access} /data/nginx/stream /var/lib/nginx/cache/{public,private}
chown root /tmp/nginx
exec nginx

View File

@ -1,4 +1,4 @@
text = True
non-interactive = True
authenticator = webroot
webroot-path = /config/letsencrypt-acme-challenge
webroot-path = /data/letsencrypt-acme-challenge

View File

@ -18,7 +18,7 @@
<p>If you're seeing this site then you're trying to access a host that isn't set up yet.</p>
<p>Log in to the Admin panel to get started.</p>
</div>
<p class="text-center"><small>Powered by <a href="#" target="_blank">Nginx Proxy Manager</a></small></p>
<p class="text-center"><small>Powered by <a href="https://github.com/jc21/nginx-proxy-manager" target="_blank">Nginx Proxy Manager</a></small></p>
</div>
</body>
</html>