From 016cce344442fc49cbe9d722548b5cd5622e4b1c Mon Sep 17 00:00:00 2001 From: Ralph Bean Date: Jan 03 2018 19:16:49 +0000 Subject: [PATCH 1/2] Try adding a dockerfile to be built by Jenkins... ... just like waiverdb. Also - build our rpm for f26, just like waiverdb. --- diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d4d9692 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM fedora:26 +LABEL \ + name="Greenwave application" \ + vendor="Greenwave developers" \ + license="GPLv2+" \ + build-date="" +# The caller should build a greenwave RPM package using ./rpmbuild.sh and then pass it in this arg. +ARG greenwave_rpm +COPY $greenwave_rpm /tmp +RUN dnf -y install \ + python-gunicorn \ + /tmp/$(basename $greenwave_rpm) \ + && dnf -y clean all +USER 1001 +EXPOSE 8080 +ENTRYPOINT gunicorn --bind 0.0.0.0:8080 --access-logfile=- greenwave.wsgi:app diff --git a/Jenkinsfile b/Jenkinsfile index 3136014..fc164a8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -68,6 +68,14 @@ node('fedora') { """ archiveArtifacts artifacts: 'mock-result/f25/**' }, + 'F26': { + sh """ + mkdir -p mock-result/f26 + flock /etc/mock/fedora-26-x86_64.cfg \ + /usr/bin/mock --resultdir=mock-result/f26 --no-cleanup-after -r fedora-26-x86_64 --clean --rebuild rpmbuild-output/*.src.rpm + """ + archiveArtifacts artifacts: 'mock-result/f26/**' + }, ) } stage('Invoke Rpmlint') { @@ -78,10 +86,41 @@ node('fedora') { 'F25': { sh 'rpmlint -f rpmlint-config.py mock-result/f25/*.rpm' }, + 'F26': { + sh 'rpmlint -f rpmlint-config.py mock-result/f26/*.rpm' + }, ) } /* XXX: run functional tests in OpenShift when UpShift is ready */ } +node('docker') { + checkout scm + stage('Build Docker container') { + unarchive mapping: ['mock-result/f26/': '.'] + def f26_rpm = findFiles(glob: 'mock-result/f26/**/*.noarch.rpm')[0] + def appversion = sh(returnStdout: true, script: """ + rpm2cpio ${f26_rpm} | \ + cpio --quiet --extract --to-stdout ./usr/lib/python2.7/site-packages/greenwave\\*.egg-info/PKG-INFO | \ + awk '/^Version: / {print \$2}' + """).trim() + /* Git builds will have a version like 0.3.2.dev1+git.3abbb08 following + * the rules in PEP440. But Docker does not let us have + in the tag + * name, so let's munge it here. */ + appversion = appversion.replace('+', '-') + docker.withRegistry( + 'https://docker-registry.engineering.redhat.com/', + 'docker-registry-factory2-builder-sa-credentials') { + /* Note that the docker.build step has some magic to guess the + * Dockerfile used, which will break if the build directory (here ".") + * is not the final argument in the string. */ + def image = docker.build "factory2/greenwave:${appversion}", "--build-arg greenwave_rpm=$f26_rpm ." + image.push() + } + /* Save container version for later steps (this is ugly but I can't find anything better...) */ + writeFile file: 'appversion', text: appversion + archiveArtifacts artifacts: 'appversion' + } +} } catch (e) { if (ownership.job.ownershipEnabled) { mail to: ownership.job.primaryOwnerEmail, From d83d2d4ddae25e2bca5a115cef2e7e9090f500e9 Mon Sep 17 00:00:00 2001 From: Ralph Bean Date: Jan 03 2018 21:56:21 +0000 Subject: [PATCH 2/2] Provide a CA cert url. --- diff --git a/Dockerfile b/Dockerfile index d4d9692..3f24fdd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,13 +4,22 @@ LABEL \ vendor="Greenwave developers" \ license="GPLv2+" \ build-date="" + # The caller should build a greenwave RPM package using ./rpmbuild.sh and then pass it in this arg. ARG greenwave_rpm +# The caller can optionally provide a cacert url +ARG cacert_url=undefined + COPY $greenwave_rpm /tmp RUN dnf -y install \ python-gunicorn \ /tmp/$(basename $greenwave_rpm) \ && dnf -y clean all +RUN if [ "$cacert_url" != "undefined" ]; then \ + cd /etc/pki/ca-trust/source/anchors \ + && curl -O --insecure $cacert_url \ + && update-ca-trust extract; \ + fi USER 1001 EXPOSE 8080 ENTRYPOINT gunicorn --bind 0.0.0.0:8080 --access-logfile=- greenwave.wsgi:app diff --git a/Jenkinsfile b/Jenkinsfile index fc164a8..3a23329 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -113,7 +113,7 @@ node('docker') { /* Note that the docker.build step has some magic to guess the * Dockerfile used, which will break if the build directory (here ".") * is not the final argument in the string. */ - def image = docker.build "factory2/greenwave:${appversion}", "--build-arg greenwave_rpm=$f26_rpm ." + def image = docker.build "factory2/greenwave:${appversion}", "--build-arg greenwave_rpm=$f26_rpm --build-arg cacert_url=https://password.corp.redhat.com/RH-IT-Root-CA.crt ." image.push() } /* Save container version for later steps (this is ugly but I can't find anything better...) */