Skip to content

Commit 015f822

Browse files
committed
Add files and fix typo in README
1 parent abcc923 commit 015f822

File tree

7 files changed

+120
-0
lines changed

7 files changed

+120
-0
lines changed

Diff for: Dockerfile

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
FROM ubuntu:14.04
2+
MAINTAINER Yasser Nabi "[email protected]"
3+
ENV JENKINS_HOME /jenkins
4+
ENV JENKINS_SWARM_CLIENT_VER 1.15
5+
ENV JENKINS_JAVA_ARGS '-Djava.awt.headless=true'
6+
ENV TZ Europe/London
7+
ENV DEBIAN_FRONTEND noninteractive
8+
EXPOSE 2812 22
9+
10+
RUN sed 's/main$/main universe/' -i /etc/apt/sources.list && \
11+
apt-get update && \
12+
apt-get -y install \
13+
openssh-server \
14+
monit \
15+
curl \
16+
openjdk-7-jre-headless \
17+
git \
18+
subversion
19+
20+
ADD ./monit.d/ /etc/monit/conf.d/
21+
ADD ./jenkins.sudoers /etc/sudoers.d/jenkins
22+
ADD ./jenkins_init_wrapper.sh /jenkins_init_wrapper.sh
23+
ADD ./start.sh /start.sh
24+
25+
RUN mkdir -p ${JENKINS_HOME} && curl -s -L -o $JENKINS_HOME/swarm-client.jar \
26+
http://maven.jenkins-ci.org/content/repositories/releases/org/jenkins-ci/plugins/swarm-client/${JENKINS_SWARM_CLIENT_VER}/swarm-client-${JENKINS_SWARM_CLIENT_VER}-jar-with-dependencies.jar
27+
28+
ENTRYPOINT ["/bin/bash", "/start.sh"]

Diff for: jenkins.sudoers

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
jenkins ALL = NOPASSWD: /usr/bin/apt-get

Diff for: jenkins_init_wrapper.sh

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/bin/bash
2+
3+
# Read Env Vars set by Docker
4+
source /docker.env
5+
6+
if ! id jenkins &>/dev/null
7+
then
8+
useradd -G monit -s /bin/bash -d ${JENKINS_HOME} jenkins
9+
10+
# Set Jenkins user password, so we can SSH
11+
JENKINS_PASSWD=$(openssl rand -base64 6)
12+
echo JENKINS_PASSWORD=${JENKINS_PASSWD}
13+
echo -e "${JENKINS_PASSWD}\n${JENKINS_PASSWD}" | passwd jenkins &>/dev/null
14+
fi
15+
16+
chown -R jenkins ${JENKINS_HOME}
17+
18+
OPTS="-fsroot ${JENKINS_HOME}"
19+
20+
if [ -n "${JENKINS_MASTER_URL}" ]
21+
then
22+
OPTS+=" -master ${JENKINS_MASTER_URL}"
23+
elif [ -n "${JENKINS_AUTODISC_ADDR}" ]
24+
then
25+
OPTS+=" -autoDiscoveryAddress ${JENKINS_AUTODISC_ADDR}"
26+
fi
27+
28+
if [ -n "${JENKINS_EXECUTORS}" ]
29+
then
30+
OPTS+=" -executors ${JENKINS_EXECUTORS}"
31+
fi
32+
33+
if [ -n "${JENKINS_LABELS}" ]
34+
then
35+
OPTS+=" -labels ${JENKINS_LABELS}"
36+
fi
37+
38+
if [ -n "${JENKINS_USERNAME}" ] && [ -n "${JENKINS_PASSWORD}" ]
39+
then
40+
OPTS+=" -username ${JENKINS_USERNAME} -password ${JENKINS_PASSWORD}"
41+
fi
42+
43+
cd ${JENKINS_HOME}
44+
echo "### Jenkins Swarm client options ###"
45+
echo "### ${OPTS} ###"
46+
case $1 in
47+
start)
48+
su - jenkins -c "java ${JENKINS_JAVA_OPTS} -jar swarm-client.jar ${OPTS} &>$JENKINS_HOME/jenkins_swarm_client.log & echo \$! > /tmp/jenkins.pid"
49+
;;
50+
stop)
51+
pkill -F /tmp/jenkins.pid
52+
;;
53+
status)
54+
if pgrep -f swarm-client.jar &>/dev/null
55+
then
56+
echo "Jenkins Swam Client running..."
57+
exit 0
58+
59+
else
60+
echo "Jenkins Swam Client not running..."
61+
exit 1
62+
fi
63+
;;
64+
*)
65+
echo "Usage $0 start|stop|status"
66+
;;
67+
esac

Diff for: monit.d/enable_monit_webserver

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
set httpd port 2812 and
2+
allow 0.0.0.0/0.0.0.0
3+
allow monit:__MONIT_PASSWD__
4+
allow @monit # allow users of group 'monit' to connect (rw)

Diff for: monit.d/jenkins

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
check process jenkins with pidfile /tmp/jenkins.pid
2+
start program = "/jenkins_init_wrapper.sh start"
3+
stop program = "/jenkins_init_wrapper.sh stop"

Diff for: monit.d/sshd

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
check process sshd with pidfile /var/run/sshd.pid
2+
start program = "/etc/init.d/ssh start"
3+
stop program = "/etc/init.d/ssh stop"
4+
if failed port 22 then restart

Diff for: start.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
env | egrep "^JENKINS|^TZ" > /docker.env
4+
5+
MONIT_PASSWD=$(openssl rand -base64 6)
6+
echo MONIT_PASSWORD=${MONIT_PASSWD}
7+
8+
groupadd monit
9+
sed -e "s/__MONIT_PASSWD__/$MONIT_PASSWD/" -i /etc/monit/conf.d/enable_monit_webserver
10+
11+
sed -e 's/\(session.*pam_loginuid.so\)/\# \1/' -i /etc/pam.d/sshd
12+
13+
/usr/bin/monit -I -g monit -v

0 commit comments

Comments
 (0)