-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathDockerfile
59 lines (46 loc) · 2.03 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
FROM jenkins/jenkins:2.138.1
# install jenkins plugins
COPY jenkins/plugins /usr/share/jenkins/plugins
COPY jenkins/install-plugins.sh /usr/share/jenkins/install-plugins.sh
RUN while read i ; \
do /usr/share/jenkins/install-plugins.sh $i ; \
done < /usr/share/jenkins/plugins
# copy jenkins jobs
ADD jenkins/jobs /usr/share/jenkins/jobs
# copy maven settings
COPY jenkins/hudson.tasks.Maven.xml /var/jenkins_home/
# copy a new entry point script to start jenkins
ADD jenkins/jenkins-entrypoint.sh /usr/local/bin/jenkins-entrypoint.sh
# copy git ssh files
COPY ssh/config /var/jenkins_home/.ssh/config
USER root
# this will be directory where we keep ssh keys for git authentication
RUN mkdir /usr/share/jenkins/ssh
# generate public/private keys for git authentication
RUN ssh-keygen -t rsa -b 4096 -C "[email protected]" -f /usr/share/jenkins/ssh/id_rsa -q -P ""
# you get "Host key verification failed" if you don't have known_hosts
# file in place or if file is empty
# add github to known_hosts
RUN ssh-keyscan -t ssh-rsa github.com >> /usr/share/jenkins/ssh/known_hosts
RUN ssh-keyscan -t ssh-rsa gitlab.apigee.com >> /usr/share/jenkins/ssh/known_hosts
# copy ssh key cat utility to image
COPY ssh/keycat.sh /usr/share/jenkins/ssh/keycat.sh
RUN chmod +x /usr/share/jenkins/ssh/keycat.sh
# let all files under ssh is owned by jenkins
RUN chown -R jenkins /usr/share/jenkins/ssh
# give permission for jenkins to update known_hosts with IP addresses of hosts
# http://askubuntu.com/a/621259
RUN chmod 600 /usr/share/jenkins/ssh/known_hosts
# private key needs to be read by jenkins user
RUN chmod 400 /usr/share/jenkins/ssh/id_rsa
# make custom entry point script executable
RUN chmod +x /usr/local/bin/jenkins-entrypoint.sh
# warm apt-get cache
RUN apt-get update
# install node.js
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -
RUN apt-get install -y nodejs
USER jenkins
ENTRYPOINT ["/sbin/tini", "--", "/usr/local/bin/jenkins-entrypoint.sh"]
# cat git authentication ssh public key so we can copy/paste
RUN /usr/share/jenkins/ssh/keycat.sh