From 15f2ff5d54ab62ace77a2899033059756ea28042 Mon Sep 17 00:00:00 2001 From: Jonathan Ervine Date: Tue, 21 Jul 2020 22:41:52 +0800 Subject: [PATCH] Switched to node builder --- Dockerfile | 25 +++++++++++-------------- Jenkinsfile | 47 ++++++++++++++++++++++++++++++++--------------- start.sh | 0 3 files changed, 43 insertions(+), 29 deletions(-) mode change 100644 => 100755 start.sh diff --git a/Dockerfile b/Dockerfile index 03e663a..1695720 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,21 @@ FROM centos:7 MAINTAINER Jonathan Ervine -RUN yum update -y -x setup && yum clean all -RUN yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm -RUN rpm --import http://packages.icinga.org/icinga.key -RUN curl -L http://packages.icinga.org/epel/ICINGA-release.repo > /etc/yum.repos.d/ICINGA-release.repo -RUN rpm -e --nodeps iputils -RUN yum install -y iputils -RUN yum makecache +RUN yum update -y -x setup && yum clean all && \ + yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm && \ + rpm --import http://packages.icinga.org/icinga.key && \ + curl -L http://packages.icinga.org/epel/ICINGA-release.repo > /etc/yum.repos.d/ICINGA-release.repo && \ + rpm -e --nodeps iputils && \ + yum install -y iputils && \ + yum makecache && \ + yum install -y centos-release-scl icinga2 nagios-plugins-all git icinga2-ido-mysql httpd php php-intl php-theseer-fDOMDocument php-gd php-pecl-imagick php-pdo php-ZendFramework-Db-Adapter-Pdo-Mysql supervisor && \ + /usr/lib/icinga2/prepare-dirs /etc/sysconfig/icinga2 && \ + usermod -a -G icingacmd apache && \ + yum install -y icingaweb2 icingacli VOLUME ["/etc/icinga2", "/etc/icingaweb2", "/var/lib/mysql", "/var/lib/icinga2"] -RUN yum install -y centos-release-scl icinga2 nagios-plugins-all git icinga2-ido-mysql httpd php php-intl php-theseer-fDOMDocument php-gd php-pecl-imagick php-pdo php-ZendFramework-Db-Adapter-Pdo-Mysql supervisor - -RUN /usr/lib/icinga2/prepare-dirs /etc/sysconfig/icinga2 -RUN usermod -a -G icingacmd apache -RUN yum install -y icingaweb2 icingacli - ADD start.sh /sbin/start.sh -RUN chmod 755 /sbin/start.sh ADD apache.ini /etc/supervisord.d/apache.ini ADD icinga2.ini /etc/supervisord.d/icinga2.ini ADD php-fm.ini /etc/supervisord.d/php-fm.ini diff --git a/Jenkinsfile b/Jenkinsfile index 4fe0a53..f3ded84 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,17 +1,34 @@ -node("docker-node") { - docker.withRegistry('https://harbor.ervine.dev', 'jenkins-to-harbor') { - - git branch: "centos7", url: "ssh://git@git.ervine.org:2222/jonny/x86_64-centos-icinga2", credentialsId: 'jenkins-to-git' - - sh "git rev-parse HEAD > .git/commit-id" - def commit_id = readFile('.git/commit-id').trim() - println commit_id - - stage "build" - def app = docker.build "library/x86_64/centos/icinga2" - - stage "publish" - app.push("${env.BUILD_NUMBER}") - app.push("latest") +podTemplate(yaml: """ +kind: Pod +spec: + containers: + - name: kaniko + image: gcr.io/kaniko-project/executor:debug-539ddefcae3fd6b411a95982a830d987f4214251 + imagePullPolicy: Always + command: + - /busybox/cat + tty: true + volumeMounts: + - name: jenkins-docker-cfg + mountPath: /kaniko/.docker + volumes: + - name: jenkins-docker-cfg + projected: + sources: + - secret: + name: regcred + items: + - key: .dockerconfigjson + path: config.json +""" + ) { + + node(POD_LABEL) { + stage('Build with Kaniko') { + git url: 'ssh://git@git.ervine.org/jonny/x86_64-centos-icinga2.git', credentialsId: 'jenkins-to-git' + container('kaniko') { + sh '/kaniko/executor -f `pwd`/Dockerfile -c `pwd` --cache=true --destination=harbor.ervine.dev/library/x86_64/centos/icinga2:7' + } } + } } diff --git a/start.sh b/start.sh old mode 100644 new mode 100755