Docker image with Jenkins CI and full PHP configuration and tools

See it in action here.

Get the source from Github here.

This Docker image follows the http://jenkins-php.org/ configuration for installing Jenkins CI and the PHP testing tools.

It uses Ubuntu 14.04 LTS image.

The PHP 5.5 PPA by Ondřej Surý is used for the latest version of PHP and its extensions.

For Jenkins the Debian deb repo is used.

The deb mirrors.ubuntu.com/mirrors.txt is used for faster local updating/downloading of the apt packages.

DEBIAN_FRONTEND=noninteractive and apt-get -qq are used for automatic silent installs.

date.timezone=Europe/Sofia and ;disable_functions= are set in php.ini

After Jenkins is installed and needs its first update there is a wait of 60 seconds until the update script is called.

The Jenkins server is first updated before installing the plugins.

Currently these plugins are installed: checkstyle cloverphp crap4j dry htmlpublisher jdepend plot pmd violations xunit.

And these PHP testing tools are installed globally through Composer: phpunit/phpunit, squizlabs/php_codesniffer, phploc/phploc, pdepend/pdepend, phpmd/phpmd, sebastian/phpcpd, theseer/phpdox.

Composer installs the tools in /home/jenkins/.composer and makes all of them available globally in /usr/local/bin/.

Composer is set to use git to fetch the dependencies to avoid the GitHub API rate limits.

Port 8080 is exposed and available. This is the default Jenkins’ port.

The default CMD in the image is: “sh /run_all.sh”

Install

First download the image:

docker pull iliyan/jenkins-ci-php:1.0.0

And run it:

Locally:

docker run -d --name jenkins -p localhost:8080:8080 iliyan/jenkins-ci-php:1.0.0

Visible from outside on a hosting server:

docker run -d --name jenkins -p VISIBLESERVERPORT:8080 iliyan/jenkins-ci-php:1.0.0

Alternative usage of the PHP testing tools:

You can download all of the tools from your project’s composer.json file adding them for example in the dev secion like I did here and here.

System-Wide PulseAudio Equalizer Updated, Added 2 Patches ~ Web Upd8: Ubuntu / Linux blog

If you value the Bass like me you will appreciate it:

System-Wide PulseAudio Equalizer Updated, Added 2 Patches ~ Web Upd8: Ubuntu / Linux blog.

Something I usually do when there is a sound distortion: I lower the volume of the desktop or web flash player and use the OS volume instead.

Setup your time on the host and inside the Docker containers

If you want to set the server’s timezone and keep it syncronized and you are using Ubuntu like me you can do the following:

On the host you can change the timezone and configure a cron to syncronize it:

dpkg-reconfigure tzdata

Pick your continent and capitol and save;

Then setup a cron to update the time daily:

echo "ntpdate ntp.ubuntu.com" > /etc/cron.daily/ntpdate && chmod 755 /etc/cron.daily/ntpdate

That’s it!

Now if you want to change the timezone inside a Docker container:

I usually have sshd running inside the containers which allows me to ssh inside them and make changes as well as reload the server process running inside to activate the changes:

docker inspect mysql_container

Now you see the ip of the container, for example: 172.17.0.2 and you use it here:

ssh 172.17.0.2

Update: now you can use docker exec to enter a container environment. Forget about running sshd server in docker containers:

docker exec -ti mycontainername bash
export TERM=xterm
#do your stuff here

Inside the container:

dpkg-reconfigure tzdata

You are not allowed to use ntpdate inside the container but it probably gets the time from the host(I still have some things to learn) and you only need the timezone set.

Another(prefered) way to make changes inside the container and keep them is to run another container from the image that the one you are going to change is running from.

docker run -ti --name mysql_container_tmp iliyan/mysql bash

Then make your changes, exit and commit the new container over the same image. Stop and remove the original container as well as the _tmp one and run a new container from the updated image. Now your changes are there!

Check this Dockerfile that automates the process (the part on the bottom that works with timezones) and also this bash script.