Created
February 14, 2017 18:50
-
-
Save courtneyfaulkner/6eb18fdf97422f3786f35d253fbc341c to your computer and use it in GitHub Desktop.
Create a Jenkins instance in DDC
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
#!/bin/bash | |
# put this in root/docker_start_master.sh | |
# Make files owned by jenkins (not root). This didn't work when done from the Dockerfile build. | |
chown -R jenkins:jenkins /var/jenkins_home | |
# Need to make sure docker.sock is in the "docker" group so that the "jenkins" user can use it: | |
chown root:docker /var/run/docker.sock | |
# Work-around a problem we're having with the container (running as a UCP service) not having DNS set-up: | |
echo "nameserver 8.8.8.8" >> /etc/resolv.conf | |
# As user jenkins, call the same command used by the base image jenkins:2.7.4-alpine | |
su -c '/bin/tini -s -- /usr/local/bin/jenkins.sh' jenkins |
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
# We use alpine base because it is smaller than Debian. | |
FROM jenkins:2.32.2-alpine | |
USER root | |
# Need to install the docker binary so that Jenkins can create images and push them. | |
# | |
# Since this image uses alpine v3.4, but we need a newer version of docker, we add a v3.5 repository and use it to install docker. | |
# This is instead of using "RUN apk update && apk add docker". | |
# | |
# Note to future maintainers: jenkins:2.7.4-alpine is based on openjdk:8-jdk-alpine which at the time of writing (1/13/2017) is based on alpine 3.4 | |
# A change to base that on Alpine 3.5 was recently reverted and may pop back up. If that does happen, py-pip needs to be renamed to py2-pip | |
# | |
RUN echo "@future http://dl-cdn.alpinelinux.org/alpine/v3.5/community" >> /etc/apk/repositories && apk add --update --no-cache \ | |
docker@future py-pip \ | |
py-pip | |
RUN pip install docker-compose | |
# Create an inode for docker.sock so that it can be volume mounted. | |
RUN touch /var/run/docker.sock | |
# Add the existing user (jenkins) to an existing group (docker), adduser is the Alpine/BusyBox way to do it: | |
RUN adduser jenkins docker | |
# config.xml is for Jenkins settings | |
COPY root /root | |
RUN chmod 700 /root/docker_start_master.sh | |
ENTRYPOINT ["/root/docker_start_master.sh"] |
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
#!/bin/bash | |
# in DTR, create a Dais organization, then create a jenkins repo in it | |
docker build -t dtr.dev.dais.com/dais/jenkins . | |
docker login dtr.dev.dais.com | |
docker push dtr.dev.dais.com/dais/jenkins |
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
#!/bin/bash | |
docker service create --name jenkins -p 30000:8080 -p 50000:50000 \ | |
--mount "type=bind,source=$PWD/docker/jenkins,target=/var/jenkins_home" \ | |
--reserve-memory 300m \ | |
dtr.dev.dais.com/dais/jenkins |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment