Dockerize Jenkins Slave for PHP project continous integration

عفوا، هذه المدخلة موجودة فقط في الإنجليزية الأمريكية. For the sake of viewer convenience, the content is shown below in the alternative language. You may click the link to switch the active language.

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

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

# 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|session    optional|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 && \
    unzip / -d /opt/ && \
    rm -fr /
COPY ./ /opt/sonar-scanner-2.6.1/conf/

# 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 | 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

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/

ExecStart=/usr/bin/docker daemon -H fd:// -H tcp://

systemctl daemon-reload
service docker restart

Build Image

docker build -t jenkinsslv-php5 .

عن Wicem

شاهد أيضاً

Configure Gatling Stress Tests command line for Jenkins

Install Gatling In order to let jenkins jobs run gatling bundle you should install the …

اترك تعليقاً

لن يتم نشر عنوان بريدك الإلكتروني. الحقول الإلزامية مشار إليها بـ *