def label = "kaniko-${UUID.randomUUID().toString()}" podTemplate( label: label, name: "kaniko", containers: [ containerTemplate( name: "kaniko", image: "gcr.io/kaniko-project/executor:debug", alwaysPullImage: true, ttyEnabled: true, command: "/busybox/cat") ], ) { node (label) { def workspace = pwd() stage("Clone Files") { sh """ git clone https://github.com/RaymiiOrg/ssl-decoder.git git clone https://github.com/RaymiiOrg/certificate-expiry-monitor.git """ } container ("kaniko") { stage("Kaniko Build & Push") { def CE = """ # Compression configuration SetOutputFilter DEFLATE BrowserMatch ^Mozilla/4 gzip-only-text/html BrowserMatch ^Mozilla/4\\.0[678] no-gzip BrowserMatch \\bMSIE !no-gzip !gzip-only-text/html SetEnvIfNoCase Request_URI \\.(?:gif|jpe?g|png)\$ no-gzip dont-vary SetEnvIfNoCase Request_URI \\.(?:exe|t?gz|zip|bz2|sit|rar)\$ no-gzip dont-vary SetEnvIfNoCase Request_URI \\.(?:avi|mov|mp3|mp4|rm|flv|swf|mp?g)\$ no-gzip dont-vary SetEnvIfNoCase Request_URI \\.pdf\$ no-gzip dont-vary DocumentRoot "/var/www/html" Require all granted Options Indexes MultiViews FollowSymLinks AllowOverride All IndexIgnore fancy-index """ def DF = """ FROM php:7-apache RUN apt-get update && \\ mkdir -p /var/www/html/ssl-decoder /var/www/html/certificate-expiry-monitor /cert-monitor && \\ apt-get install -y \\ libicu-dev \\ python2 \\ gettext \\ python-netaddr \\ libcurl4-openssl-dev \\ libonig-dev \\ libxml2-dev \\ libglib2.0-dev \\ libgnutls28-dev \\ automake \\ libtool && \\ apt-get clean && \\ printf '%s\\\n' "sendmail_path = /usr/local/bin/msmtp -t -i" >> /usr/local/etc/php/php.ini && \\ cd /tmp && \\ curl -L https://marlam.de/msmtp/releases/msmtp-1.8.8.tar.xz -o msmtp.tar.xz && \\ tar -x -f msmtp.tar.xz && \\ cd msmtp-1.8.8 && \\ autoreconf -i && \\ ./configure && \\ make && \\ make install && \\ rm -rf /tmp/msmtp && \\ touch /var/log/msmtp.log && \\ chmod 777 /var/log/msmtp.log && \\ cd /var/www/html && \\ docker-php-ext-install intl bcmath curl mbstring xml COPY linux-webserver.conf /etc/apache2/sites-enabled/linux-webserver.conf COPY ssl-decoder /var/www/html/ssl-decoder COPY certificate-expiry-monitor /var/www/html/certificate-expiry-monitor COPY variables.php /var/www/html/certificate-expiry-monitor/functions/variables.php COPY msmtprc /usr/local/etc/msmtprc RUN printf '%s' "{}" > /cert-monitor/pre_checks.json && \\ printf '%s' "{}" > /cert-monitor/checks.json && \\ printf '%s' "{}" > /cert-monitor/deleted_checks.json && \\ chown -R 33:33 /var/www/html/* /cert-monitor && \\ sed -i '18s/^.*\$/error_reporting(E_ERROR | E_PARSE);/' /var/www/html/ssl-decoder/index.php && \\ sed -i '18s/^.*\$/error_reporting(E_ERROR | E_PARSE);/' /var/www/html/certificate-expiry-monitor/index.php && \\ sed -i '17s/^.*\$/error_reporting(E_ERROR | E_PARSE);/' /var/www/html/certificate-expiry-monitor/add.php && \\ sed -i '17s/^.*\$/error_reporting(E_ERROR | E_PARSE);/' /var/www/html/certificate-expiry-monitor/confirm.php && \\ sed -i '17s/^.*\$/error_reporting(E_ERROR | E_PARSE);/' /var/www/html/certificate-expiry-monitor/unsubscribe.php """ writeFile file: workspace + '/linux-webserver.conf', text: AC writeFile file: workspace + '/variables.php', text: CE writeFile file: workspace + '/Dockerfile', text: DF writeFile file: workspace + '/msmtprc', text: MC sh '/kaniko/executor --insecure --skip-tls-verify --context "' + workspace + '" -f "' + workspace + '/Dockerfile" --destination registry.test-chamber-13.lan:5000/raymii:latest' } } } }