Last active
June 15, 2024 20:30
-
-
Save GMaissa/705b6c685a6b576c802b to your computer and use it in GitHub Desktop.
Installation script for Jenkins+Docker on Debian Wheezy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Update wheezy kernel as it requires at least a kernel 3.11.x | |
echo "deb http://http.debian.net/debian wheezy-backports main" >> /etc/apt/sources.list | |
aptitude update | |
aptitude install -y -t wheezy-backports linux-image-amd64 | |
mv /etc/grub.d/06_OVHkernel /root/ | |
update-grub | |
reboot | |
# Install jenkins | |
echo "deb http://pkg.jenkins-ci.org/debian binary/" > /etc/apt/sources.list.d/jenkins.list | |
wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | apt-key add - | |
aptitude update | |
aptitude install -y jenkins openjdk-7-jre | |
service jenkins start | |
# Install docker | |
curl -sSL https://get.docker.com/ | sh | |
groupadd docker | |
gpasswd -a jenkins docker | |
cat << EOF > /etc/default/docker | |
DOCKER_OPTS="-H 127.0.0.1:4243 -H unix:///var/run/docker.sock" | |
EOF | |
service docker restart | |
# Generate a docker image for our containers | |
docker run debian:wheezy cat /etc/apt/sources.list | |
cat << EOF > Dockerfile | |
FROM debian:wheezy | |
RUN apt-get update | |
RUN apt-get install -y apt-utils | |
RUN apt-get install -y openssh-server openjdk-7-jre-headless sudo | |
RUN apt-get install -y libapache2-mod-php5 php5 php5-cli php5-xdebug php5-common php5-curl curl git-core | |
RUN curl -sS https://getcomposer.org/installer | php | |
RUN mv composer.phar /usr/local/bin/composer | |
RUN useradd -m --uid=104 --home /home/jenkins -s /bin/bash jenkins | |
RUN echo jenkins:jenkins | chpasswd | |
RUN gpasswd -a jenkins sudo | |
ADD id_rsa /home/jenkins/.ssh/id_rsa | |
ADD id_rsa.pub /home/jenkins/.ssh/id_rsa.pub | |
RUN chown -R jenkins /home/jenkins/.ssh | |
RUN echo "jenkins ALL=(root)NOPASSWD: ALL" > /etc/sudoers.d/jenkins | |
RUN service sudo restart | |
RUN mkdir -p /var/run/sshd | |
# Create known_hosts | |
RUN touch /home/jenkins/.ssh/known_hosts | |
# Remove host checking | |
RUN echo "Host bitbucket.org\n\tStrictHostKeyChecking no\n" >> /home/jenkins/.ssh/config | |
RUN echo "Host github.com\n\tStrictHostKeyChecking no\n" >> /home/jenkins/.ssh/config | |
ENV HOME /home/jenkins | |
USER jenkins | |
WORKDIR /build | |
VOLUME ["/build"] | |
EXPOSE 22 | |
CMD ["/bin/bash", "travis-tests.sh"] | |
EOF | |
docker build -t nova-jenkins:wheezy . | |
# Installing commands to convert .travis.yml into shell script | |
aptitude install -y python-pip | |
pip install shyaml | |
# TODO : provide informations about jenkins plugins to install | |
wget http://localhost:8080/jnlpJars/jenkins-cli.jar | |
java -jar jenkins-cli.jar -s http://localhost:8080 install-plugin checkstyle cloverphp crap4j dry htmlpublisher jdepend plot pmd violations xunit | |
java -jar jenkins-cli.jar -s http://localhost:8080 safe-restart | |
curl -L https://raw.githubusercontent.com/sebastianbergmann/php-jenkins-template/master/config.xml | \ | |
java -jar jenkins-cli.jar -s http://localhost:8080 create-job php-template |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment