FROM debian8

# OS packages needed to build OpenMPI.
RUN apt-get install -y \
    file \
    flex \
    g++ \
    gcc \
    gfortran \
    less \
    libdb5.3-dev \
    make \
    wget

# Compile OpenMPI. We can't use the Debian package because
# --disable-pty-support is needed to avoid "pipe function call failed when
# setting up I/O forwarding subsystem".
ENV MPI_URL https://www.open-mpi.org/software/ompi/v1.10/downloads
ENV MPI_VERSION 1.10.5
WORKDIR /usr/src
RUN wget -nv ${MPI_URL}/openmpi-${MPI_VERSION}.tar.gz
RUN tar xf openmpi-${MPI_VERSION}.tar.gz
RUN    cd openmpi-${MPI_VERSION} \
    && CFLAGS=-O3 \
       CXXFLAGS=-O3 \
       ./configure --prefix=/usr \
                   --sysconfdir=/mnt/0 \
                   --disable-pty-support \
    && make -j$(getconf _NPROCESSORS_ONLN) install
RUN rm -Rf openmpi-${MPI_VERSION}*
