FROM centos:7
MAINTAINER Chad Barraford <chad@rstudio.com>

# EPEL
RUN yum -y install epel-release

# RPMForge
RUN     rpm -Uvh http://mirror.chpc.utah.edu/pub/repoforge/redhat/el7/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm

# SSH
EXPOSE 22
RUN yum -y groupinstall "Development tools"
RUN yum -y install rsyslog screen passwd java-1.7.0-openjdk sudo wget git python3 tar python3-devel mercurial gcc glibc-devel xorg-x11-server-Xvfb firefox pam-devel


# There's a networking bug with some versions of git which sometimes causes
# 'go get' to hang; force a git update.
#
# http://stackoverflow.com/questions/21820715/how-to-install-latest-version-of-git-on-centos-6-x
# https://groups.google.com/forum/#!topic/golang-nuts/RKz9ASmJm3o
RUN yum -y --disablerepo=base,updates --enablerepo=rpmforge-extras update git

RUN yum install -y python3-setuptools python3-unittest2
RUN yum install -y R curl libcurl-devel

RUN yum -y install centos-release-scl
RUN yum -y install devtoolset-11

# Use cmake 3.21.3 (newer is probably fine too). Must avoid 3.18-3.20 due to %posttrans issue
RUN wget -q https://github.com/Kitware/CMake/releases/download/v3.21.3/cmake-3.21.3-linux-x86_64.tar.gz
RUN tar xzf cmake-3.21.3-linux-x86_64.tar.gz -C /usr/local --strip-components=1

# create jenkins user, make sudo. try to keep this toward the bottom for less cache busting
ARG JENKINS_GID=512
ARG JENKINS_UID=512
RUN groupadd -g $JENKINS_GID jenkins && \
    useradd -m -d /var/lib/jenkins -u $JENKINS_UID -g jenkins jenkins && \
    echo "jenkins ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
