The Jenkins Continuous Integration and Delivery server, plus some PHP packages and Plugins for PHP CI projects. It follows the recommendations from jenkins-php.org.
This is a fully functional Jenkins server, based on the Long Term Support release. http://jenkins.io/.
docker run -p 8080:8080 -p 50000:50000 edobarroso/jenkins-php
NOTE: read below the build executors part for the role of the 50000
port mapping.
This will store the workspace in /var/jenkins_home. All Jenkins data lives in there - including plugins and configuration. You will probably want to make that an explicit volume so you can manage it and attach to another container for upgrades :
docker run -p 8080:8080 -p 50000:50000 -v jenkins_home:/var/jenkins_home edobarroso/jenkins-php
this will automatically create a 'jenkins_home' volume on docker host, that will survive container stop/restart/deletion.
Avoid using a bind mount from a folder on host into /var/jenkins_home
, as this might result in file permission issue. If you really need to bind mount jenkins_home, ensure that directory on host is accessible by the jenkins user in container (jenkins user - uid 1000) or use -u some_other_user
parameter with docker run
.
If you bind mount in a volume - you can simply back up that directory (which is jenkins_home) at any time.
This is highly recommended. Treat the jenkins_home directory as you would a database - in Docker you would generally put a database on a volume.
If your volume is inside a container - you can use docker cp $ID:/var/jenkins_home
command to extract the data, or other options to find where the volume data is.
Note that some symlinks on some OSes may be converted to copies (this can confuse jenkins with lastStableBuild links etc)
For more info check Docker docs section on Managing data in containers
-
PHP7.0
-
PHP7.0-xdebug
-
PHP7.0-xsl
-
PHP7.0-dom
-
PHP7.0-zip
-
PHP7.0-mbstring
-
Checkstyle (for processing PHP_CodeSniffer logfiles in Checkstyle format)
-
Clover PHP (for processing PHPUnit's Clover XML logfile)
-
HTML Publisher (for publishing documentation generated by phpDox, for instance)
-
JDepend (for processing PHP_Depend logfiles in JDepend format)
-
Violations (for processing various logfiles)
-
Warnings (for processing PHP compiler warnings in the console log)
You can specify and set the number of executors of your Jenkins master instance using a groovy script. By default its set to 2 executors, but you can extend the image and change it to your desired number of executors :
executors.groovy
import jenkins.model.*
Jenkins.instance.setNumExecutors(5)
and Dockerfile
FROM jenkins
COPY executors.groovy /usr/share/jenkins/ref/init.groovy.d/executors.groovy
You can run builds on the master out of the box.
But if you want to attach build slave servers through JNLP (Java Web Start): make sure you map the port: -p 50000:50000
- which will be used when you connect a slave agent.
If you are only using SSH slaves, then you do NOT need to put that port mapping.
You might need to customize the JVM running Jenkins, typically to pass system properties or tweak heap memory settings. Use JAVA_OPTS environment variable for this purpose :
docker run --name myjenkins -p 8080:8080 -p 50000:50000 --env JAVA_OPTS=-Dhudson.footerURL=http://mycompany.com edobarroso/jenkins-php
Jenkins logging can be configured through a properties file and java.util.logging.config.file
Java property.
For example:
mkdir data
cat > data/log.properties <<EOF
handlers=java.util.logging.ConsoleHandler
jenkins.level=FINEST
java.util.logging.ConsoleHandler.level=FINEST
EOF
docker run --name myjenkins -p 8080:8080 -p 50000:50000 --env JAVA_OPTS="-Djava.util.logging.config.file=/var/jenkins_home/log.properties" -v `pwd`/data:/var/jenkins_home edobarroso/jenkins-php
If you want to install Jenkins behind a reverse proxy with prefix, example: mysite.com/jenkins, you need to add environnement variable JENKINS_OPTS="--prefix=/jenkins"
and then follow the below procedures to configure your reverse proxy, which will depend if you have Apache ou Nginx: