r-builds/builder/Dockerfile.centos-6
Greg Lin 374827079c Fix pip installation on CentOS 6
Previously, the pip install was failing with:
InsecurePlatformWarning: A true SSLContext object is not available.
2020-04-24 10:35:02 -05:00

225 lines
7.9 KiB
Text

FROM centos:centos6
ENV OS_IDENTIFIER centos-6
RUN yum -y update \
&& yum -y install \
bzip2-devel \
cairo-devel \
gcc-c++ \
gcc-gfortran \
gcc-objc \
glibc-devel \
groff \
java-1.8.0-openjdk-devel \
krb5-devel \
krb5-libs \
libICE-devel \
libSM-devel \
libX11-devel \
libXmu-devel \
libXt-devel \
libgssapi-devel \
libicu-devel \
libidn-devel \
libjpeg-devel \
libpng-devel \
libssh2-devel \
libtiff-devel \
ncurses-devel \
openldap \
openldap-devel \
openssh-clients \
openssh-server \
openssl-devel \
pango-devel \
pcre-devel \
pkgconfig \
python \
readline-devel \
rpm-build \
stunnel \
tcl-devel \
texinfo-tex \
texlive-latex \
tk-devel \
valgrind-devel \
wget \
xz-devel \
zlib-devel \
&& yum clean all
# Install pip
RUN yum install -y epel-release && \
yum install -y python-pip
# Install AWS CLI.
RUN pip install awscli --upgrade --user && \
ln -s /root/.local/bin/aws /usr/bin/aws
RUN chmod 0777 /opt
# Compile newer versions of zlib, bzip2, xz, pcre, and curl.
#
# Several compression libraries that were at one time included in R-devel have been removed.
# Instead of providing these libraries, R-devel assumes they are pre-installed. On RedHat 6,
# this results in build errors when zlib, bzip, pcre, curl, and xz are required. These
# libraries must be downloaded and compiled before building R-devel. Reference:
# http://pj.freefaculty.org/blog/?p=315
#
# It's also import to build the static versions of these libraries and link them
# statically when building R. This allows us to use the R binaries we build on
# another CentOS/RHEL 6 OS without updating the same five libraries.
# For more info, see the "R.spec" RPM spec file in the EPEL source archive at:
# http://download-ib01.fedoraproject.org/pub/epel/7/SRPMS/Packages/r/R-3.5.2-2.el7.src.rpm
# (search for "zlibhack" in R.spec).
#
# First, reate a directory for the additional libraries.
RUN mkdir -p /tmp/extra
# zlib 1.2.8
#
# Note: zlib 1.2.11 works fine for all R versions except 3.3.0, 3.3.1, and 3.3.2,
# so I went with an older version (1.2.8) to accommodate the flaky R versions. See the
# following note on https://www.r-statistics.com/2017/03/r-3-3-3-is-released/:
#
# The configure check for the zlib version is now robust to versions longer than 5 characters,
# including 1.2.11.
#
ARG ZLIB_VERSION=1.2.8
ARG ZLIB_DOWNLOAD_SHA256=36658cb768a54c1d4dec43c3116c27ed893e88b02ecfcb44f2166f9c0b7f2a0d
RUN curl -fsSL "https://zlib.net/fossils/zlib-${ZLIB_VERSION}.tar.gz" -o zlib.tar.gz \
&& echo "$ZLIB_DOWNLOAD_SHA256 zlib.tar.gz" | sha256sum -c - \
&& CWD=`pwd` && TMP=`mktemp -d` \
&& tar -C $TMP -zxvf zlib.tar.gz \
&& cd $TMP/zlib* \
&& ./configure --prefix=/tmp/extra --static \
&& make CFLAGS="-fpic -fPIC" \
&& make install \
&& cd $CWD && rm -rf $TMP && rm -rf zlib.tar.gz
# bzip2 1.0.6
ARG BZIP2_VERSION=1.0.6
ARG BZIP2_DOWNLOAD_SHA1=3f89f861209ce81a6bab1fd1998c0ef311712002
RUN curl -fsSL "https://sourceforge.net/projects/bzip2/files/bzip2-{$BZIP2_VERSION}.tar.gz/download" -o bzip2.tar.gz \
&& echo "$BZIP2_DOWNLOAD_SHA1 bzip2.tar.gz" | sha1sum -c - \
&& CWD=`pwd` && TMP=`mktemp -d` \
&& tar -C $TMP -zxvf bzip2.tar.gz \
&& cd $TMP/bzip2* \
&& make libbz2.a CFLAGS="-D_FILE_OFFSET_BITS=64 -fpic -fPIC" PREFIX=/tmp/extra \
&& make install PREFIX=/tmp/extra \
&& cd $CWD && rm -rf $TMP && rm -rf bzip2.tar.gz
# xz 5.2.4 (for lzma libraries)
ARG XZ_VERSION=5.2.4
ARG XZ_DOWNLOAD_SHA1=63ca380029597b951ce9afc6dec28f44f70bb5bd
RUN curl -fsSL "https://sourceforge.net/projects/lzmautils/files/xz-{$XZ_VERSION}.tar.gz/download" -o xz.tar.gz \
&& echo "$XZ_DOWNLOAD_SHA1 xz.tar.gz" | sha1sum -c - \
&& CWD=`pwd` && TMP=`mktemp -d` \
&& tar -C $TMP -zxvf xz.tar.gz \
&& cd $TMP/xz* \
&& CFLAGS="-fpic -fPIC" ./configure --enable-static=yes --enable-shared=no --prefix=/tmp/extra \
&& make -j8 \
&& make install \
&& cd $CWD && rm -rf $TMP && rm -rf xz.tar.gz
# PCRE 8.42
#
# The PCRE library provides PGP signatures for verifying downloads. Originally, I tried to do some
# PGP validation in the Dockerfile, but I ran into trouble with flaky key servers. To streamline
# things, I verified the download manually and then generated a sha256 checksum with the following
# commands:
# gpg --recv-key FB0F43D8
# gpg pcre-8.42.tar.gz.sig
# sha256sum pcre-8.42.tar.gz
#
ARG PCRE_VERSION=8.42
ARG PCRE_DOWNLOAD_SHA256=69acbc2fbdefb955d42a4c606dfde800c2885711d2979e356c0636efde9ec3b5
RUN curl -fsSL "https://ftp.pcre.org/pub/pcre/pcre-{$PCRE_VERSION}.tar.gz" -o pcre.tar.gz \
&& echo "$PCRE_DOWNLOAD_SHA256 pcre.tar.gz" | sha256sum -c - \
&& CWD=`pwd` && TMP=`mktemp -d` \
&& tar -C $TMP -zxvf pcre.tar.gz \
&& cd $TMP/pcre* \
&& mkdir -p /tmp/extra \
&& CFLAGS="-fpic -fPIC" ./configure --enable-static=yes --enable-shared=no --enable-utf --enable-unicode-properties --enable-pcre8 --enable-pcre16 --enable-pcre32 --prefix=/tmp/extra \
&& make -j8 \
&& make install \
&& cd $CWD && rm -rf $TMP && rm -rf pcre.tar.gz
# Curl 7.63.0
#
# The curl library provides PGP signatures for verifying downloads. Originally, I tried to do some
# PGP validation in the Dockerfile, but I ran into trouble with flaky key servers. To streamline
# things, I verified the download manually and then generated a sha256 checksum with the following
# commands:
# gpg --recv-key B71E12C2
# gpg curl-7.63.0.tar.gz.asc
# sha256sum curl-7.63.0.tar.gz
#
ARG CURL_VERSION=7.63.0
ARG CURL_DOWNLOAD_SHA256=d483b89062832e211c887d7cf1b65c902d591b48c11fe7d174af781681580b41
RUN curl -fsSL "https://curl.haxx.se/download/curl-{$CURL_VERSION}.tar.gz" -o curl.tar.gz \
&& echo "$CURL_DOWNLOAD_SHA256 curl.tar.gz" | sha256sum -c - \
&& CWD=`pwd` && TMP=`mktemp -d` \
&& tar -C $TMP -zxvf curl.tar.gz \
&& cd $TMP/curl* \
&& CFLAGS="-fpic -fPIC" ./configure --enable-static=yes --enable-shared=no --with-ssl --enable-ipv6 --with-gssapi --with-libidn --enable-ldaps --with-libssh2 --enable-threaded-resolver --prefix=/tmp/extra \
&& make V=1 \
&& make install \
&& cd $CWD && rm -rf $TMP && rm -rf curl.tar.gz
# Compiler and linker flags for statically linking updated libraries
ENV CFLAGS="-fpic -fPIC -I/tmp/extra/include"
ENV CURL_CFLAGS='-DCURL_STATICLIB -I/tmp/extra/include'
ENV CURL_CPPFLAGS='-DCURL_STATICLIB -I/tmp/extra/include'
# Configure flags for CentOS 6 that don't use the defaults in build.sh
ENV CONFIGURE_OPTIONS="\
--enable-R-shlib \
--with-tcltk \
--enable-memory-profiling \
--with-x \
--with-system-valgrind-headers \
--with-tcl-config=/usr/lib64/tclConfig.sh \
--with-tk-config=/usr/lib64/tkConfig.sh \
--enable-prebuilt-html"
# RHEL 6 doesn't have texi2any, so use makeinfo.
ENV MAKEINFO=makeinfo
# RHEL 6 doesn't have the inconsolata font, so override the defaults.
ENV R_RD4PDF="times,hyper"
#-- required for fpm --
## install rvm
RUN curl -sSL https://rvm.io/mpapis.asc | gpg2 --import - \
&& curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import - \
&& curl -L get.rvm.io | bash -s stable
## use rvm to install ruby
RUN source /etc/profile.d/rvm.sh \
&& /usr/local/rvm/bin/rvm reload \
&& /usr/local/rvm/bin/rvm requirements run \
&& /usr/local/rvm/bin/rvm install 2.6.3 \
&& /usr/local/rvm/bin/rvm use 2.6.3 --default
# RUN gem install fpm -v 0.4.26
RUN export PATH=/usr/local/rvm/rubies/ruby-2.6.3/bin/:/.gems/bin:${PATH} \
&& export GEM_HOME=/.gems \
&& export GEM_PATH=/.gems \
&& gem install --no-document fpm \
&& /usr/local/rvm/bin/rvm repair wrappers
RUN echo 'source /etc/profile.d/rvm.sh' >> .bashrc
#----------------------
# Copy a script to help set up the environment
COPY env_centos6.sh ./env.sh
COPY package.centos-6 /package.sh
COPY build.sh .
# Copy a script to clean up after the build
COPY clean_centos6.sh ./clean.sh
ENTRYPOINT ./build.sh