Public Repository

Last pushed: 2 years ago
Short Description
Generic Jenkins slave image for Kubernetes
Full Description

Has java and Maven. Uses JNLP

FROM centos
ENV JENKINS_REMOTING_VERSION 2.52

RUN echo "root:test123" | chpasswd
RUN yum install -y wget
RUN wget -O /opt/apache-maven-3.2.5-bin.tar.gz http://archive.apache.org/dist/maven/maven-3/3.2.5/binaries/apache-maven-3.2.5-bin.tar.gz
RUN tar -xvf /opt/apache-maven-3.2.5-bin.tar.gz -C /opt/
RUN ln -s /opt/apache-maven-3.2.5/bin/mvn /usr/bin/mvn
RUN yum install -y git fontconfig freetype-devel bzip2 npm
ENV HOME=/root
ENV LANG=en_US.UTF-8
ENV LC_ALL=en_US.UTF-8
RUN yum install -y curl; yum upgrade -y; yum update -y;  yum clean all
ENV JDK_VERSION=8u71
ENV JDK_BUILD_VERSION=b15
RUN curl -LO "http://download.oracle.com/otn-pub/java/jdk/$JDK_VERSION-$JDK_BUILD_VERSION/jdk-$JDK_VERSION-linux-x64.rpm" -H 'Cookie: oraclelicense=accept-securebackup-cookie' && rpm -i jdk-$JDK_VERSION-linux-x64.rpm; rm -f jdk-$JDK_VERSION-linux-x64.rpm; yum clean all
ENV JAVA_HOME=/usr/java/default




RUN curl --create-dirs -sSLo /usr/share/jenkins/remoting-$JENKINS_REMOTING_VERSION.jar http://repo.jenkins-ci.org/public/org/jenkins-ci/main/remoting/$JENKINS_REMOTING_VERSION/remoting-$JENKINS_REMOTING_VERSION.jar && chmod 755 /usr/share/jenkins


COPY jenkins-slave.sh /usr/local/bin/jenkins-slave.sh
RUN chmod +x /usr/local/bin/jenkins-slave.sh
ENTRYPOINT ["/usr/local/bin/jenkins-slave.sh"]

And the starup script is

#!/bin/bash
# Usage jenkins-slave.sh [options] -url http://jenkins SECRET SLAVE_NAME
# if `docker run` has 2 or more arguments the user is passing jenkins launcher arguments
if [[ $# -gt 1 ]]; then
# jenkins slave
JAR=`ls -1 /usr/share/jenkins/remoting-*.jar | tail -n 1`
PARAMS=""
# if -url is not provided try env vars
if [[ "$@" != *"-url "* ]]; then
if [ ! -z "$JENKINS_URL" ]; then
PARAMS="$PARAMS -url $JENKINS_URL"
elif [ ! -z "$JENKINS_SERVICE_HOST" ] && [ ! -z "$JENKINS_SERVICE_PORT" ]; then
PARAMS="$PARAMS -url http://$JENKINS_SERVICE_HOST:$JENKINS_SERVICE_PORT"
fi
fi
# if -tunnel is not provided try env vars
if [[ "$@" != *"-tunnel "* ]]; then
if [ ! -z "$JENKINS_TUNNEL" ]; then
PARAMS="$PARAMS -tunnel $JENKINS_TUNNEL"
elif [ ! -z "$JENKINS_SLAVE_SERVICE_HOST" ] && [ ! -z "$JENKINS_SLAVE_SERVICE_PORT" ]; then
PARAMS="$PARAMS -tunnel $JENKINS_SLAVE_SERVICE_HOST:$JENKINS_SLAVE_SERVICE_PORT"
fi
fi
echo Running java $JAVA_OPTS -cp $JAR hudson.remoting.jnlp.Main -headless $PARAMS "$@"
exec java $JAVA_OPTS -cp $JAR hudson.remoting.jnlp.Main -headless $PARAMS "$@"
fi
# As argument is not jenkins, assume user want to run his own process, for sample a `bash` shell to explore this image
exec "$@"
Docker Pull Command
Owner
sivashchenko