Ian Maxon | ab00616 | 2019-04-04 21:00:41 -0700 | [diff] [blame^] | 1 | FROM centos:7.2.1511 |
| 2 | |
| 3 | USER root |
| 4 | |
| 5 | RUN yum install -y openssh-server openssh-clients unzip git which |
| 6 | |
| 7 | # Set up for SSH daemon |
| 8 | RUN sed -ri -e 's/UsePAM yes/#UsePAM yes/g' \ |
| 9 | -e 's/#UsePAM no/UsePAM no/g' \ |
| 10 | -e 's/^GSS/#GSS/' \ |
| 11 | -e '/ssh_host_ed25519_key/d' \ |
| 12 | /etc/ssh/sshd_config && \ |
| 13 | ssh-keygen -f /etc/ssh/ssh_host_ecdsa_key -N '' -t ecdsa && \ |
| 14 | ssh-keygen -f /etc/ssh/ssh_host_rsa_key -N '' -t rsa && \ |
| 15 | ssh-keygen -f /etc/ssh/ssh_host_dsa_key -N '' -t dsa |
| 16 | |
| 17 | # -e 's@#HostKey /etc/ssh/ssh_host_dsa_key@HostKey /etc/ssh/ssh_host_dsa_key@g' \ |
| 18 | |
| 19 | # JDK. |
| 20 | RUN mkdir /tmp/deploy && \ |
| 21 | cd /tmp/deploy && \ |
| 22 | curl -L --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" \ |
| 23 | http://download.oracle.com/otn-pub/java/jdk/8u102-b14/jdk-8u102-linux-x64.rpm \ |
| 24 | -o jdk.rpm && \ |
| 25 | yum localinstall -y jdk.rpm && \ |
| 26 | cd /tmp && rm -rf deploy |
| 27 | ENV JAVA_HOME=/usr/java/latest |
| 28 | |
| 29 | # create jenkins user |
| 30 | RUN groupadd -g1000 jenkins && \ |
| 31 | useradd jenkins -g jenkins -u1000 -m -s /bin/bash && \ |
| 32 | echo "jenkins:$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo)" | chpasswd |
| 33 | |
| 34 | COPY startup.sh /usr/sbin/ |
| 35 | COPY ssh/* /home/jenkins/.ssh/ |
| 36 | RUN chown -R jenkins:jenkins /home/jenkins/.ssh && \ |
| 37 | chmod 600 /home/jenkins/.ssh/* |
| 38 | |
| 39 | # Configure password-less ssh for user jenkins |
| 40 | USER jenkins |
| 41 | RUN ssh-keygen -q -t rsa -P "" < /dev/zero && \ |
| 42 | cat /home/jenkins/.ssh/id_rsa.pub >> /home/jenkins/.ssh/authorized_keys && \ |
| 43 | chmod 600 /home/jenkins/.ssh/authorized_keys |
| 44 | |
| 45 | # Configure the Jenkins non-interactive logins with UTF-8 |
| 46 | RUN echo "export LANG=en_US.UTF-8" >> /home/jenkins/.bashrc |
| 47 | |
| 48 | USER root |
| 49 | ENTRYPOINT [ "/usr/sbin/startup.sh" ] |
| 50 | CMD [ "default" ] |
| 51 | EXPOSE 22 8000-8003 |