-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
126 lines (91 loc) · 5.16 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
FROM ubuntu
ENV MAVEN_HOME /usr/share/maven
ENV JAVA_HOME /usr
ENV NODEJS_HOME=/usr/lib/nodejs/node
ENV HOME /home/jenkins
#Override from Build arguments , below are defaulted if not
ARG JENKINS_SLAVE_VERSION=3.29
ARG MAVEN_VERSION=3.6.1
ARG NODE_VERSION=10.9.0
ARG HELM_VERSION=v2.14.3
ARG TERRAFORM_VERSION=0.12.6
ARG PACKER_VERSION=1.4.2
ARG JAVA_VERSION=8=8.40.0.25
ARG AGENT_WORKDIR=/home/jenkins/agent
# ARG JAVA_VERSION=9 # refer for versions https://github.com/zulu-openjdk
LABEL Description="Extending Jenkins agent executable (slave.jar) for building projects"
USER root
# Install necessary Packages
RUN apt-get --allow-unauthenticated update && apt-get --allow-unauthenticated upgrade -yq && \
apt-get --allow-unauthenticated install --no-install-recommends -yq build-essential openssl openssh-client apt-transport-https gnupg2\
ca-certificates software-properties-common apt-utils locales libapr1 curl wget jq git vim bash\
libtcnative-1 python3.6 python3-pip python3-setuptools \
gettext unzip iputils-ping file net-tools
# Add Docker repos
RUN curl -k -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
RUN add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
RUN apt-get --allow-unauthenticated update && apt-get --allow-unauthenticated install -yq docker-ce
# Install zulu open-jdk
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0xB1998361219BD9C9 \
&& echo "deb http://repos.azulsystems.com/ubuntu stable main" >> /etc/apt/sources.list.d/zulu.list \
&& apt-get -q --allow-unauthenticated update && apt-get -yq --allow-unauthenticated install zulu-$JAVA_VERSION
# Install maven
RUN curl -k -fsSL http://archive.apache.org/dist/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz | tar xzf - -C /usr/share \
&& mv /usr/share/apache-maven-$MAVEN_VERSION /usr/share/maven \
&& ln -s /usr/share/maven/bin/mvn /usr/bin/mvn
# Add chrome for protractor tests
RUN wget --no-check-certificate -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
# Install node.js https://nodejs.org/en/download/
RUN mkdir /usr/lib/nodejs \
&& curl -k -fsSL "http://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.gz" | tar xz --directory "/usr/lib/nodejs" \
&& mv /usr/lib/nodejs/node-v$NODE_VERSION-linux-x64 /usr/lib/nodejs/node
ENV PATH="$NODEJS_HOME/bin:/home/jenkins/.global-modules/bin:$PATH$PATH"
# Install Kubectl
RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl \
&& chmod +x ./kubectl \
&& mv ./kubectl /usr/local/bin/kubectl
# Install Ansible
RUN pip3 install ansible
RUN echo "==> Adding hosts for convenience..." && \
mkdir -p /etc/ansible /ansible && \
echo "[local]" >> /etc/ansible/hosts && \
echo "localhost ansible_connection=local ansible_python_interpreter=/usr/bin/python3" >> /etc/ansible/hosts
# Override hosts in base images or replacing contents of /etc/ansible/hosts at runtime with volumes
ADD ansible.cfg /etc/ansible/ansible.cfg
# Install Helm
RUN curl -kL https://storage.googleapis.com/kubernetes-helm/helm-${HELM_VERSION}-linux-amd64.tar.gz | tar xz \
&& mv linux-amd64/helm /usr/bin/helm \
&& rm -rf linux-amd64
# Install Terraform
RUN wget --quiet -nc https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip \
&& unzip terraform_${TERRAFORM_VERSION}_linux_amd64.zip -d /usr/bin \
&& rm -rf terraform_${TERRAFORM_VERSION}_linux_amd64.zip
# Install Packer
RUN wget --quiet -nc https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_linux_amd64.zip \
&& unzip packer_${PACKER_VERSION}_linux_amd64.zip -d /usr/bin \
&& rm -rf packer_${PACKER_VERSION}_linux_amd64.zip
# AWS tools installation
RUN pip3 install awscli boto3
RUN mkdir ~/.aws && touch ~/.aws/credentials
# Install Slave jenkins jars
RUN curl -k --create-dirs -fsSLo /usr/share/jenkins/slave.jar https://repo.jenkins-ci.org/public/org/jenkins-ci/main/remoting/${JENKINS_SLAVE_VERSION}/remoting-${JENKINS_SLAVE_VERSION}.jar \
&& chmod 755 /usr/share/jenkins \
&& chmod 644 /usr/share/jenkins/slave.jar
COPY jenkins-slave /usr/local/bin/jenkins-slave
ENV AGENT_WORKDIR=${AGENT_WORKDIR}
RUN mkdir /home/jenkins/.jenkins && mkdir -p ${AGENT_WORKDIR} && chmod 777 /usr/local/bin/jenkins-slave
VOLUME /home/jenkins/.jenkins
VOLUME ${AGENT_WORKDIR}
WORKDIR /home/jenkins
# Adhoc Commands
#RUN apt-get --allow-unauthenticated update && apt-get --allow-unauthenticated -yq install file net-tools
RUN mkdir ~/.global-modules && npm config set prefix "~/.global-modules"
RUN npm install -g @angular/cli --unsafe
# Custom settings.xml
#ADD maven_settings.xml $MAVEN_HOME/conf/settings.xml
# Custom npmrc
#ADD npmrc /home/jenkins/.npmrc
# Clean up
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
ENTRYPOINT ["sh","/usr/local/bin/jenkins-slave"]