diff --git a/Dockerfile b/Dockerfile index 09cfc5d..98d6f18 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,6 @@ -FROM trafex/alpine-nginx-php7:2.0.2 +ARG UPSTREAM_IMAGE=trafex/alpine-nginx-php7:2.0.2 + +FROM $UPSTREAM_IMAGE LABEL maintainer="Robert Schumann " @@ -13,7 +15,7 @@ COPY ./manifest/ / RUN set -x \ && apk update \ - && apk add bash expat-dev mariadb-dev mariadb-client mariadb-connector-c openssl gzip wget perl-utils g++ make perl-dev \ + && apk add bash expat-dev mariadb-dev mariadb-client mariadb-connector-c openssl openssl-dev gzip wget perl-utils g++ make perl-dev \ && wget -4 -q --no-check-certificate -O parser.zip $REPORT_PARSER_SOURCE \ && wget -4 -q --no-check-certificate -O viewer.zip $REPORT_VIEWER_SOURCE \ && unzip parser.zip && cp -av dmarcts-report-parser-master/* /usr/bin/ && rm -vf parser.zip && rm -rvf dmarcts-report-parser-master \ @@ -24,12 +26,11 @@ RUN set -x \ && sed -i 's%.*root /var/www/html;% root /var/www/viewer;%g' /etc/nginx/nginx.conf \ && sed -i 's/.*index index.php index.html;/ index dmarcts-report-viewer.php;/g' /etc/nginx/nginx.conf \ && sed -i 's%files = /etc/supervisor.d/\*.ini%files = /etc/supervisor/conf.d/*.conf%g' /etc/supervisord.conf \ - && chmod 755 /entrypoint.sh \ && (echo y;echo o conf prerequisites_policy follow;echo o conf commit)|cpan \ && for i in \ + IO::Socket::SSL \ CPAN \ CPAN::DistnameInfo \ - IO::Socket::SSL \ File::MimeInfo \ IO::Compress::Gzip \ Getopt::Long \ @@ -47,7 +48,7 @@ RUN set -x \ Socket6 \ PerlIO::gzip \ ; do cpan install $i; done \ - && apk del mariadb-dev expat-dev perl-dev g++ make + && apk del mariadb-dev expat-dev openssl-dev perl-dev g++ make HEALTHCHECK --interval=1m --timeout=3s CMD curl --silent --fail http://127.0.0.1:80/fpm-ping diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..345d65d --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,68 @@ +DOCKER_IMAGE = '' +DOCKER_ARGS = '--network=services_default' +DOCKER_REGISTRY = 'registry.n-os.org:5000' +DOCKER_REPO = "${JOB_BASE_NAME}" + +properties([ + parameters([ + string(defaultValue: '3.11', name: 'UPSTREAM_IMAGE', description: "Upstream docker image to start with") + ]) +]) + +node { + try { + setBuildStatus('build started', 'PENDING') + pipeline() + setBuildStatus('build succeeded', 'SUCCESS') + } + catch(e) { + setBuildStatus('build failed', 'FAILURE') + throw e + } + finally { + cleanup() + } +} + +def pipeline() { + stage('checkout') { + checkout scm + } + + stage('image build') { + DOCKER_IMAGE = docker.build( + "${DOCKER_REGISTRY}/${DOCKER_REPO}:${BUILD_ID}", + "--build-arg UPSTREAM_IMAGE=${UPSTREAM_IMAGE}" + + "--no-cache ${DOCKER_ARGS} ." + ) + } + + // stage('run tests') { + // DOCKER_IMAGE.inside("${DOCKER_ARGS} --entrypoint=") { + // sh 'bats /usr/build/test/*.bats' + // } + // } + + stage('push image') { + def shortHash = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim() + DOCKER_IMAGE.push() + DOCKER_IMAGE.push(shortHash) + } +} + +def cleanup() { + stage('schedule cleanup') { + build job: '../Maintenance/dangling-container-cleanup', wait: false + } +} + +void setBuildStatus(message, state) { + def repoUrl = sh(script: 'git config --get remote.origin.url', returnStdout: true).trim() + step([ + $class: "GitHubCommitStatusSetter", + reposSource: [$class: "ManuallyEnteredRepositorySource", url: repoUrl], + contextSource: [$class: "ManuallyEnteredCommitContextSource", context: "ci/jenkins/build-status"], + errorHandlers: [[$class: "ChangingBuildStatusErrorHandler", result: "UNSTABLE"]], + statusResultSource: [ $class: "ConditionalStatusResultSource", results: [[$class: "AnyBuildResult", message: message, state: state]] ] + ]); +} diff --git a/manifest/entrypoint.sh b/manifest/entrypoint.sh old mode 100644 new mode 100755