We saw in a previous posts how to prepare a Jenkins server for a php countinous integration. int his post we try to configure a docker server and containers for lunching the jenkins job on the slave.
Install Docker
Be feeling tutorial on https://docs.docker.com/engine/installation/linux/ubuntulinux/
Prepare PHP Slave
# This Dockerfile is used to build an image containing basic stuff to be used as a Jenkins slave build node.
FROM ubuntu:trusty
MAINTAINER Wicem KERKENI "myemail"
# Make sure the package repository is up to date.
RUN apt-get update && \
apt-get -y upgrade
# Install a basic SSH server
RUN apt-get install -y openssh-server
RUN sed -i 's|session required pam_loginuid.so|session optional pam_loginuid.so|g' /etc/pam.d/sshd
RUN mkdir -p /var/run/sshd
# Install a JDK
RUN apt-get update && \
apt-get install -y software-properties-common python-software-properties unzip wget && \
echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | debconf-set-selections && \
add-apt-repository -y ppa:webupd8team/java && \
apt-get update && \
apt-get install -y oracle-java8-installer && \
apt-get clean
ENV JAVA_HOME /usr/lib/jvm/java-8-oracle
# Add SVN && GIT
RUN apt-get update && \
apt-get install -y git subversion lsof && \
apt-get clean
# Add Sonar Runner
RUN wget https://sonarsource.bintray.com/Distribution/sonar-scanner-cli/sonar-scanner-2.6.1.zip && \
unzip /sonar-scanner-2.6.1.zip -d /opt/ && \
rm -fr /sonar-scanner-2.6.1.zip
COPY ./sonar-scanner.properties /opt/sonar-scanner-2.6.1/conf/sonar-scanner.properties
# Install php5 delivered from trusty ubuntu repo
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y php5 curl php5-curl php5-xsl php5-sqlite php5-xdebug php5-sybase php5-json php5-mcrypt php5-memcache php5-mysql php5-readline php5-sqlite && \
apt-get clean
#Install Extended tools
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y ant nodejs npm && \
npm install -g bower && \
ln -s /usr/bin/nodejs /usr/bin/node && \
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && \
apt-get clean
# Add user jenkins to the image
RUN adduser --quiet jenkins
# Set password for the jenkins user (you may want to alter this).
RUN echo "jenkins:jenkins" | chpasswd
# Standard SSH port
EXPOSE 22
Permit Docker service to bind on TCP in order to be contacted remotely (eg. by Jenkins). On Ubuntu Server you must change docker.service file.
vi /etc/systemd/system/multi-user.target.wants/docker.service ... ExecStart=/usr/bin/docker daemon -H fd:// -H tcp://0.0.0.0:4243 ....
systemctl daemon-reload service docker restart
Build Image
docker build -t jenkinsslv-php5 .

Français
العربية