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> MAINTAINER Jamie Curnow <jc@jc21.com>
LABEL 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 ENV S6_FIX_ATTRS_HIDDEN=1
RUN echo "fs.file-max = 65535" > /etc/sysctl.conf 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 # root filesystem
COPY rootfs / COPY rootfs /
@ -17,15 +30,13 @@ RUN curl -L -o /tmp/s6-overlay-amd64.tar.gz "https://github.com/just-containers/
# App # App
ENV NODE_ENV=production ENV NODE_ENV=production
#ADD LICENCE /srv/manager/LICENCE ADD dist /srv/app/dist
#ADD README.md /srv/manager/README.md ADD node_modules /srv/app/node_modules
ADD manager/dist /srv/manager/dist ADD src/backend /srv/app/src/backend
ADD manager/node_modules /srv/manager/node_modules ADD package.json /srv/app/package.json
ADD manager/src/backend /srv/manager/src/backend
ADD manager/package.json /srv/manager/package.json
# Volumes # Volumes
VOLUME [ "/config", "/etc/letsencrypt" ] VOLUME [ "/data", "/etc/letsencrypt" ]
CMD [ "/init" ] CMD [ "/init" ]
HEALTHCHECK --interval=15s --timeout=3s CMD curl -f http://localhost:9876/health || exit 1 HEALTHCHECK --interval=15s --timeout=3s CMD curl -f http://localhost:9876/health || exit 1

17
Jenkinsfile vendored
View File

@ -1,6 +1,6 @@
pipeline { pipeline {
options { options {
buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '10')) buildDiscarder(logRotator(numToKeepStr: '10'))
disableConcurrentBuilds() disableConcurrentBuilds()
} }
agent any agent any
@ -13,16 +13,17 @@ pipeline {
stage('Prepare') { stage('Prepare') {
steps { steps {
sh 'docker pull jc21/$IMAGE_NAME-base' sh 'docker pull jc21/$IMAGE_NAME-base'
sh 'docker pull jc21/node'
sh 'docker pull $DOCKER_CI_TOOLS' sh 'docker pull $DOCKER_CI_TOOLS'
} }
} }
stage('Build') { stage('Build') {
steps { 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):/srv/app -w /srv/app jc21/node 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 bin/build'
sh 'rm -rf node_modules' 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):/srv/app -w /srv/app jc21/node 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):/data $DOCKER_CI_TOOLS node-prune'
sh 'docker build --squash --compress -t $TEMP_IMAGE_NAME .' sh 'docker build --squash --compress -t $TEMP_IMAGE_NAME .'
} }
} }
@ -51,11 +52,11 @@ pipeline {
} }
post { post {
success { success {
slackSend color: "#72c900", message: "SUCCESS: <${BUILD_URL}|${JOB_NAME}> build #${BUILD_NUMBER} - ${currentBuild.durationString}" juxtapose event: 'success'
sh 'figlet "SUCCESS"' sh 'figlet "SUCCESS"'
} }
failure { failure {
slackSend color: "#d61111", message: "FAILED: <${BUILD_URL}|${JOB_NAME}> build #${BUILD_NUMBER} - ${currentBuild.durationString}" juxtapose event: 'failure'
sh 'figlet "FAILURE"' sh 'figlet "FAILURE"'
} }
always { always {
@ -65,6 +66,6 @@ pipeline {
} }
def getPackageVersion() { 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() return ver.trim()
} }

View File

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

View File

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

View File

@ -1,6 +1,6 @@
#!/usr/bin/with-contenv bash #!/usr/bin/with-contenv bash
mkdir -p /config/letsencrypt-acme-challenge mkdir -p /data/letsencrypt-acme-challenge
cd /srv/manager cd /srv/app
node --abort_on_uncaught_exception --max_old_space_size=250 /srv/manager/src/backend/index.js 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 #!/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 chown root /tmp/nginx
exec nginx exec nginx

View File

@ -1,4 +1,4 @@
text = True text = True
non-interactive = True non-interactive = True
authenticator = webroot 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>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> <p>Log in to the Admin panel to get started.</p>
</div> </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> </div>
</body> </body>
</html> </html>