Public Repository

Last pushed: a year ago
Short Description
golang-jenkins-slave-redhat-rpmbuild
Full Description

FROM rhel6.7
MAINTAINER Thomas Nakaki tnakaki@directv.com

get yum repos

copy VMWARE_TOOL_OSP.repo /etc/yum.repos.d/
copy RHEL6_UPDATES_SNAPSHOT.repo /etc/yum.repos.d/
copy RHEL6_OPTIONAL.repo /etc/yum.repos.d/
copy RHEL6_ISO_LB.repo /etc/yum.repos.d/

#copy puias_6.repo /etc/yum.repos.d/

#copy mirrors-rpmforge /etc/yum.repos.d/

#copy ius.repo /etc/yum.repos.d/

#copy graphviz-rhel.repo /etc/yum.repos.d/
copy dtv-updates.repo /etc/yum.repos.d/

#copy rpmforge.repo /etc/yum.repos.d/
copy RHEL6_UPDATES.repo /etc/yum.repos.d/
copy RHEL6_ISO_SRV.repo /etc/yum.repos.d/
copy RHEL6_ISO_HA.repo /etc/yum.repos.d/

#copy mirrors-rpmforge-testing /etc/yum.repos.d/
copy jenkins.repo /etc/yum.repos.d/

#copy ius-dev.repo /etc/yum.repos.d/

#copy epel-testing.repo /etc/yum.repos.d/
copy dtv-rpm-releases.repo /etc/yum.repos.d/
copy rhel-source.repo /etc/yum.repos.d/
copy RHEL6_SUPPLEMENTARY.repo /etc/yum.repos.d/
copy RHEL6_ISO.repo /etc/yum.repos.d/
copy RHEL6_CUSTOM.repo /etc/yum.repos.d/

#copy mirrors-rpmforge-extras /etc/yum.repos.d/

#copy ius-testing.repo /etc/yum.repos.d/

#copy ius-archive.repo /etc/yum.repos.d/
copy epel.repo /etc/yum.repos.d/
copy docker-main.repo /etc/yum.repos.d/

#RUN yum update -y
RUN yum install -y tar.x86_64
RUN yum install -y which wget && yum clean packages

get yum repos

RHEL/CentOS 6 64 Bit OS

#RUN wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm

#RUN rpm -Uvh rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm

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

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 'jenkins'

RUN yum -y install sudo
RUN sed -i 's/requiretty/!requiretty/' /etc/sudoers
RUN echo 'jenkins ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
RUN sudo groupadd -g 10000 jenkins

#RUN sudo useradd -c "Jenkins user" -u 10000 -g 10000 -m jenkins
RUN useradd -d /home/jenkins -u 10000 -g 10000 -p openssl passwd -1 "jenkins" jenkins

RUN useradd -d /home/jenkins -p openssl passwd -g 10000 -1 "jenkins" jenkins

RUN sudo -ujenkins rpmdev-setuptree
RUN sudo -ujenkins 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: 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 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)