#38 build a Docker container in Jenkins
Merged 6 years ago by dcallagh. Opened 7 years ago by dcallagh.
dcallagh/waiverdb docker  into  master

file added
+10
@@ -0,0 +1,10 @@ 

+ FROM centos:7

+ RUN yum -y install epel-release && yum -y clean all

+ # The caller should build a waiverdb RPM package using ./rpmbuild.sh and then pass it in this arg.

+ ARG waiverdb_rpm

+ COPY $waiverdb_rpm /tmp

+ # XXX take out epel-testing eventually

+ RUN yum -y install --setopt=tsflags=nodocs --enablerepo=epel-testing python-gunicorn /tmp/$(basename $waiverdb_rpm) && yum -y clean all

+ USER 1001

+ EXPOSE 8080

+ ENTRYPOINT gunicorn --bind 0.0.0.0:8080 --access-logfile=- waiverdb.wsgi:app

file modified
+29 -14
@@ -22,20 +22,35 @@ 

      /* We take a flock on the mock configs, to avoid multiple unrelated jobs on 

       * the same Jenkins slave trying to use the same mock root at the same 

       * time, which will error out. */

-     stage('Build RPM (EPEL7)') {

-         sh """

-         mkdir -p mock-result/el7

-         flock /etc/mock/epel-7-x86_64.cfg \

-         /usr/bin/mock --resultdir=mock-result/el7 -r epel-7-x86_64 --clean --rebuild rpmbuild-output/*.src.rpm

-         """

-         archiveArtifacts artifacts: 'mock-result/el7/**'

+     stage('Build RPM') {

+         parallel (

+             'EPEL7': {

+                 sh """

+                 mkdir -p mock-result/el7

+                 flock /etc/mock/epel-7-x86_64.cfg \

+                 /usr/bin/mock --resultdir=mock-result/el7 -r epel-7-x86_64 --clean --rebuild rpmbuild-output/*.src.rpm

+                 """

+                 archiveArtifacts artifacts: 'mock-result/el7/**'

+             },

+             'F25': {

+                 sh """

+                 mkdir -p mock-result/f25

+                 flock /etc/mock/fedora-25-x86_64.cfg \

+                 /usr/bin/mock --resultdir=mock-result/f25 -r fedora-25-x86_64 --clean --rebuild rpmbuild-output/*.src.rpm

+                 """

+                 archiveArtifacts artifacts: 'mock-result/f25/**'

+             },

+         )

      }

-     stage('Build RPM (F25)') {

-         sh """

-         mkdir -p mock-result/f25

-         flock /etc/mock/fedora-25-x86_64.cfg \

-         /usr/bin/mock --resultdir=mock-result/f25 -r fedora-25-x86_64 --clean --rebuild rpmbuild-output/*.src.rpm

-         """

-         archiveArtifacts artifacts: 'mock-result/f25/**'

+ }

+ node('rcm-tools-jslave-rhel-7-docker') {

+     checkout scm

+     stage('Build Docker container') {

+         unarchive mapping: ['mock-result/el7/': '.']

+         def el7_rpm = findFiles(glob: 'mock-result/el7/**/*.noarch.rpm')[0]

+         /* 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 'waiverdb', "--build-arg waiverdb_rpm=$el7_rpm ."

      }

  }

The intention is to use this container as part of an OpenShift application deployment.

Looks fine to me, although I didn't verify it.

I haven't yet figured out what exactly to do with the Docker container, but it does indeed build successfully. :-)

Pull-Request has been merged by dcallagh

6 years ago
Metadata