Skip to content

Commit c2aa075

Browse files
committed
Initial Checkin
0 parents  commit c2aa075

21 files changed

+1488
-0
lines changed

docker-compose.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# This version maps
2+
# Jenkins to http://your-host/jenkins
3+
# Sonar to http://your-host/sonar
4+
# If you want to change the mapping you have to do
5+
# the following.
6+
# Jenkins: Edit Dockerfile of Jenkinst (--prefix=/jenkins) at top
7+
# Edit location in the reverse-proxy.conf
8+
# Sonar: Edit sonar.properties in directory sonar.properties
9+
# Edit location in the reverse-proxy.conf
10+
11+
version: "3"
12+
services:
13+
14+
ngnix:
15+
build: nginx-reverse
16+
ports:
17+
- "80:80"
18+
19+
jenkins-fat:
20+
build: jenkins-fat
21+
# Change this if your lokal-DNS Server does not match, use to resolve your local host via local DNS
22+
dns: 192.168.178.1
23+
volumes:
24+
- jenkins_home:/var/jenkins_home
25+
- /var/run/docker.sock:/var/run/docker.sock
26+
sonar-db:
27+
image: postgres
28+
environment:
29+
- POSTGRES_USER=sonar
30+
- POSTGRES_PASSWORD=sonar
31+
volumes:
32+
- postgresql:/var/lib/postgresql
33+
# This needs explicit mapping due to
34+
# https://github.com/docker-library/postgres/blob/4e48e3228a30763913ece952c611e5e9b95c8759/Dockerfile.template#L52
35+
- postgresql_data:/var/lib/postgresql/data
36+
37+
sonar:
38+
build: sonarqube-custom
39+
# Change this if your lokal-DNS Server does not match, use to resolve your local host via local DNS
40+
dns: 192.168.178.1
41+
environment:
42+
- SONARQUBE_JDBC_URL=jdbc:postgresql://sonar-db:5432/sonar
43+
volumes:
44+
- sonarqube_conf:/opt/sonarqube/conf
45+
- sonarqube_data:/opt/sonarqube/data
46+
- sonarqube_extensions:/opt/sonarqube/extensions
47+
- sonarqube_bundled-plugins:/opt/sonarqube/lib/bundled-plugins
48+
49+
#These are docker-volumes, reside in /var/lib/docker
50+
# ... consider host-volumes if you want to have an easy backup
51+
volumes:
52+
sonarqube_conf:
53+
sonarqube_data:
54+
sonarqube_extensions:
55+
sonarqube_bundled-plugins:
56+
postgresql:
57+
postgresql_data:
58+
jenkins_home:
59+
jenkins_home_docker:
60+
61+

jenkins-fat/CONTRIBUTING.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Issues and Contributing
2+
3+
Please note that only issues related to this Docker image will be addressed here.
4+
5+
* If you have Docker related issues, please ask in the [Docker user mailing list](https://groups.google.com/forum/#!forum/docker-user).
6+
* If you have Jenkins related issues, please ask in the [Jenkins mailing lists](https://jenkins-ci.org/content/mailing-lists).
7+
* If you are not sure, then this is probably not the place to create an issue and you should use any of the previously mentioned mailing lists.
8+
9+
If after going through the previous checklist you still think you should create an issue here please provide:
10+
11+
* Docker commands that you execute
12+
* Actual result
13+
* Expected outcome
14+
* Have you tried a non-dockerized Jenkins and get the expected outcome?
15+
* Output of `docker version`
16+
* Other relevant information

jenkins-fat/Dockerfile

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
FROM ubuntu:17.04
2+
ENV DEBIAN_FRONTEND noninteractive
3+
ENV JAVA_VERSION=8 \
4+
JAVA_UPDATE=131 \
5+
JAVA_BUILD=11 \
6+
JAVA_HOME="/usr/lib/jvm/default-jvm"
7+
# update dpkg repositories and install tools
8+
RUN apt-get update
9+
RUN apt-get install -y openjdk-8-jdk
10+
RUN apt-get install -y --no-install-recommends apt-utils
11+
RUN apt-get install -y git
12+
RUN apt-get install -y wget
13+
RUN apt-get install -y curl
14+
RUN apt-get install -y graphviz
15+
16+
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64
17+
18+
# This is the line for the Jenkins prefix to set ... remember
19+
# to set the location in the reverse-proxy.conf
20+
ENV JENKINS_OPTS="--webroot=/var/cache/jenkins/war --prefix=/jenkins"
21+
22+
#-----------------------------------------------
23+
# install Oracle Java if you want ... and
24+
# remove the line "RUN apt-get install -y openjdk-8-jdk"
25+
# above ... but openjdk is pretty good !
26+
#-----------------------------------------------
27+
#------------ Download
28+
# ## ENV filename jdk-8u131-linux-x64.tar.gz
29+
# ## ENV downloadlink http://download.oracle.com/otn-pub/java/jdk/${JAVA_VERSION}u${JAVA_UPDATE}-b${JAVA_BUILD}/d54c1d3a095b4ff2b6607d096fa80163/jdk-${JAVA_VERSION}u${JAVA_UPDATE}-linux-x64.tar.gz
30+
# ## RUN wget --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" -O /tmp/$filename $downloadlink
31+
# ---- unpack java
32+
# ## ENV UNPACK_DIR=jdk1.8.0_131/
33+
# ## RUN mkdir -p /opt/ && tar -zxf /tmp/$filename -C /opt/ && ln -s /opt/${UNPACK_DIR} /opt/java
34+
# ## ENV JAVA_HOME /opt/java
35+
#----------------------------------------
36+
# install Maven
37+
#----------------------------------------
38+
# get maven 3.2.0
39+
RUN wget --no-verbose -O /tmp/apache-maven-3.2.5.tar.gz http://archive.apache.org/dist/maven/maven-3/3.2.5/binaries/apache-maven-3.2.5-bin.tar.gz
40+
# verify checksum
41+
RUN echo "b2d88f02bd3a08a9df1f0b0126ebd8dc /tmp/apache-maven-3.2.5.tar.gz" | md5sum -c
42+
# install maven
43+
RUN tar xzf /tmp/apache-maven-3.2.5.tar.gz -C /opt/
44+
RUN ln -s /opt/apache-maven-3.2.5 /opt/maven
45+
ENV MAVEN_HOME /opt/maven
46+
ENV PATH $MAVEN_HOME/bin:$JAVA_HOME/bin:$PATH
47+
48+
RUN apt-get update && apt-get install -y zip unzip
49+
RUN rm -rf /opt/java/src.zip && rm -rf /tmp/$filename
50+
RUN rm -f /tmp/apache-maven-3.2.5.tar.gz
51+
#------------------------------
52+
# install Jenkins
53+
#------------------------------
54+
ENV JENKINS_HOME /var/jenkins_home
55+
ENV JENKINS_SLAVE_AGENT_PORT 50000
56+
ARG user=jenkins
57+
ARG group=jenkins
58+
ARG uid=1000
59+
ARG gid=1000
60+
# Jenkins is run with user `jenkins`, uid = 1000
61+
# If you bind mount a volume from the host or a data container,
62+
# ensure you use the same uid
63+
RUN groupadd -g ${gid} ${group} && useradd -d "$JENKINS_HOME" -u ${uid} -g ${gid} -m -s /bin/bash ${user}
64+
# Jenkins home directory is a volume, so configuration and build history
65+
# can be persisted and survive image upgrades
66+
67+
VOLUME /var/jenkins_home
68+
69+
# `/usr/share/jenkins/ref/` contains all reference configuration we want
70+
# to set on a fresh new installation. Use it to bundle additional plugins
71+
# or config file with your custom jenkins Docker image.
72+
RUN mkdir -p /usr/share/jenkins/ref/init.groovy.d && mkdir /tmp
73+
ENV TINI_VERSION 0.14.0
74+
ENV TINI_SHA 6c41ec7d33e857d4779f14d9c74924cab0c7973485d2972419a3b7c7620ff5fd
75+
# Use tini as subreaper in Docker container to adopt zombie processes
76+
RUN curl -fsSL https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini-static-amd64 -o /bin/tini && chmod +x /bin/tini \
77+
&& echo "$TINI_SHA /bin/tini" | sha256sum -c -
78+
79+
COPY init.groovy /usr/share/jenkins/ref/init.groovy.d/tcp-slave-agent-port.groovy
80+
81+
# jenkins version being bundled in this docker image
82+
ARG JENKINS_VERSION
83+
ENV JENKINS_VERSION ${JENKINS_VERSION:-2.71}
84+
85+
# jenkins.war checksum, download will be validated using it
86+
ARG JENKINS_SHA=71b2b5ba6d7fca261325682639ba604b7b889e7e
87+
88+
# Can be used to customize where jenkins.war get downloaded from http://updates.jenkins-ci.org/download/war/2.57/jenkins.war
89+
ARG JENKINS_URL=https://repo.jenkins-ci.org/public/org/jenkins-ci/main/jenkins-war/${JENKINS_VERSION}/jenkins-war-${JENKINS_VERSION}.war
90+
91+
# could use ADD but this one does not check Last-Modified header neither does it allow to control checksum
92+
# see https://github.com/docker/docker/issues/8331
93+
RUN curl -fsSL ${JENKINS_URL} -o /usr/share/jenkins/jenkins.war && echo "${JENKINS_SHA} /usr/share/jenkins/jenkins.war" | sha1sum -c -
94+
95+
96+
ENV JENKINS_UC https://updates.jenkins.io
97+
RUN chown -R ${user} "$JENKINS_HOME" /usr/share/jenkins/ref
98+
99+
# for main web interface:
100+
EXPOSE 8080
101+
102+
ENV COPY_REFERENCE_FILE_LOG $JENKINS_HOME/copy_reference_file.log
103+
104+
USER ${user}
105+
106+
COPY jenkins-support /usr/local/bin/jenkins-support
107+
COPY jenkins.sh /usr/local/bin/jenkins.sh
108+
109+
ENV JAVA_OPTIONS="-Djava.awt.headless=true -Dhudson.security.csrf.requestfield=crumb"
110+
111+
112+
ENTRYPOINT ["/bin/tini", "--", "/usr/local/bin/jenkins.sh"]
113+
#-----------------------------------------------
114+
# get all Plugins from existing Jenins
115+
#-----------------------------------------------
116+
# JENKINS_HOST=username:password@myhost.com:port
117+
# curl -sSL "http://$JENKINS_HOST/pluginManager/api/xml?depth=1&xpath=/*/*/shortName|/*/*/version&wrapper=plugins" | perl -pe 's/.*?<shortName>([\w-]+).*?<version>([^<]+)()(<\/\w+>)+/\1 \2\n/g'|sed 's/ /:/'
118+
119+
120+
# ----------------------------------------------------
121+
COPY plugins.sh /usr/local/bin/plugins.sh
122+
COPY install-plugins.sh /usr/local/bin/install-plugins.sh
123+
# Install additional plugins
124+
COPY plugins.txt /usr/share/jenkins/ref/
125+
RUN /usr/local/bin/plugins.sh /usr/share/jenkins/ref/plugins.txt
126+
127+
128+
129+
130+
131+
USER root
132+
133+
RUN apt-get clean
134+
135+
136+
137+

jenkins-fat/Jenkinsfile

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env groovy
2+
3+
properties([
4+
buildDiscarder(logRotator(numToKeepStr: '5', artifactNumToKeepStr: '5')),
5+
pipelineTriggers([cron('@daily')]),
6+
])
7+
8+
node('docker') {
9+
deleteDir()
10+
11+
stage('Checkout') {
12+
checkout scm
13+
}
14+
15+
16+
17+
if (!infra.isTrusted()) {
18+
/* Outside of the trusted.ci environment, we're building and testing
19+
* the Dockerful in this repository, but not publishing to docker hub
20+
*/
21+
stage('Build') {
22+
docker.build('jenkins')
23+
}
24+
25+
stage('Test') {
26+
sh """
27+
git submodule update --init --recursive
28+
git clone https://github.com/sstephenson/bats.git
29+
bats/bin/bats tests
30+
"""
31+
}
32+
} else {
33+
/* In our trusted.ci environment we only want to be publishing our
34+
* containers from artifacts
35+
*/
36+
stage('Publish') {
37+
sh './publish.sh'
38+
}
39+
}
40+
}

0 commit comments

Comments
 (0)