Public Repository

Last pushed: a year ago
Short Description
jenkins-slave-centos-rpmbuild-go
Full Description

FROM centos:7.2.1511
MAINTAINER Thomas Nakaki tnakaki@directv.com
RUN yum install -y which wget && yum clean packages

Install up-to-date epel rpm repository

RHEL/CentOS 7 64-Bit

RUN yum -y install http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-8.noarch.rpm
RUN sed -i '/^[centosplus]$/,/^[/ s/^enabled=0$/enabled=1/' /etc/yum.repos.d/CentOS-Base.repo
RUN yum install -y openssl

Install various packages to get compile environment

RUN yum -y groupinstall 'Development Tools'

Install git command to access GitHub repository

RUN yum -y install git
RUN yum -y install wget curl

Install rpm-build to use rpmrebuild command

RUN yum -y install rpm-build

Install yum-utils to use yumdownloader command

RUN yum -y install yum-utils

Install rpmdevtools to use rpmdev-setuptree command

RUN yum -y install rpmdevtools

Setup sshd to accept login

RUN yum -y install openssh-server

#RUN sed -ri 's/UsePAM yes/#UsePAM yes/g' /etc/ssh/sshd_config

#RUN sed -ri 's/#UsePAM no/UsePAM no/g' /etc/ssh/sshd_config

#RUN /etc/init.d/sshd start

#RUN /etc/init.d/sshd stop

#EXPOSE 22

Set up SSH

RUN mkdir /var/run/sshd && mkdir /var/log/ssh

Set up SSH Host Key

RUN /usr/bin/ssh-keygen -q -t rsa1 -f /etc/ssh/ssh_host_key -C '' -N ''
RUN chmod 600 /etc/ssh/ssh_host_key && chmod 644 /etc/ssh/ssh_host_key.pub
RUN /usr/bin/ssh-keygen -q -t rsa -f /etc/ssh/ssh_host_rsa_key -C '' -N ''
RUN chmod 600 /etc/ssh/ssh_host_rsa_key && chmod 644 /etc/ssh/ssh_host_rsa_key.pub
RUN /usr/bin/ssh-keygen -q -t dsa -f /etc/ssh/ssh_host_dsa_key -C '' -N ''
RUN chmod 600 /etc/ssh/ssh_host_dsa_key && chmod 644 /etc/ssh/ssh_host_dsa_key.pub

Set up SSHD config

RUN sed -i 's|session required pam_loginuid.so|session optional pam_loginuid.so|g' /etc/pam.d/sshd
RUN sed -ri 's/UsePAM yes/#UsePAM yes/g' /etc/ssh/sshd_config && sed -ri 's/#UsePAM no/UsePAM no/g' /etc/ssh/sshd_config

#END SSHD configuration

Setup rpm build configuration for root user

RUN rpmdev-setuptree
RUN echo '%_topdir %(echo $HOME)/rpmbuild' > ~/.rpmmacros

Setup rpm build configuration for general user 'build'

RUN yum -y install sudo
RUN sed -i 's/requiretty/!requiretty/' /etc/sudoers
RUN echo 'build ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
RUN useradd -d /home/build -p openssl passwd -1 "build" build
RUN sudo -ubuild rpmdev-setuptree
RUN sudo -ubuild echo '%_topdir %(echo $HOME)/rpmbuild' > ~/.rpmmacros

Set environment variables

ENV HOME /root
WORKDIR /root/rpmbuild
RUN echo "PATH=$PATH" | sudo tee /etc/environment
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

Install Java.

ENV JAVA_VERSION 8u112
ENV BUILD_VERSION b112

Downloading Java

#RUN wget --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/$JAVA_VERSION-$BUILD_VERSION/jdk-$JAVA_VERSION-linux-x64.rpm" -O /tmp/jdk-8-linux-x64.rpm
RUN wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F;oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u112-b15/jdk-8u112-linux-x64.rpm -O /tmp/jdk-8-linux-x64.rpm
RUN yum -y install /tmp/jdk-8-linux-x64.rpm

Define commonly used JAVA_HOME variable

ENV JAVA_HOME /usr/java/latest
RUN ["java","-version"]

Bypass loginuid as Docker drops some audit-related capabilities

(see http://stackoverflow.com/questions/2...ue-with-docker)

RUN sudo sed -i 's/session\srequired\spam_loginuid.so/session optional pam_loginuid.so/g' /etc/pam.d/sshd
RUN sudo mkdir -p /var/run/sshd

Set password for the jenkins user (you may want to alter this)

RUN sudo groupadd -g 10000 jenkins
RUN sudo useradd -c "Jenkins user" -u 10000 -g 10000 -m jenkins
RUN echo "jenkins:jenkins" | chpasswd
RUN echo "root:Docker!" | chpasswd

Enable Sudo for Jenkins User

RUN usermod -aG wheel jenkins

Enable passwordless sudo for users under the "sudo" group

RUN sed -i.bkp -e 's/%wheel\s+ALL=(ALL(:ALL)\?)\s+ALL/%wheel ALL=NOPASSWD:ALL/g' /etc/sudoers

#setupm GOLANG
ENV GO_VERSION 1.7
RUN yum -y install wget curl && \
wget https://storage.googleapis.com/golang/go${GO_VERSION}.linux-amd64.tar.gz && \
tar -C /usr/local -xzf go1.7.linux-amd64.tar.gz
ENV GOROOT /usr/local/go
ENV PATH $PATH:$GOROOT/bin
RUN echo "export GOROOT=/usr/local/go" >> /home/jenkins/.bashrc
RUN echo -e "export PATH=\$PATH:\$GOROOT/bin" >> /home/jenkins/.bashrc
RUN ["go","version"]

End Golang setup

Standard SSH port

EXPOSE 22

##########################################

prepare jenkins slave run env

##########################################
ENV HOME /home/jenkins
WORKDIR $HOME
USER root
RUN mkdir /home/jenkins/.tmp
VOLUME ["/home/jenkins"]

Default command

CMD ["/usr/sbin/sshd", "-D"]

Docker Pull Command
Owner
tnakaki1234

Comments (0)