# note: this containerfile was derived from NERSC's mpich build
# as of this commit, it's on a PR branch here: https://gitlab.com/NERSC/nersc-official-images/-/merge_requests/6
ARG ACCT="C-Worthy"
ARG FROM_TAG="latest"
ARG IMG_BUILDBASE="$ACCT/cstar-buildbase:$FROM_TAG"

FROM $IMG_BUILDBASE
SHELL ["/bin/bash", "-c"]
ENV DEBIAN_FRONTEND noninteractive
WORKDIR /tmp


ARG mpich=4.2.2
ARG mpich_prefix=mpich-$mpich

ARG ncpus $(( $nproc / 8 ))
RUN \
    wget https://www.mpich.org/static/downloads/$mpich/$mpich_prefix.tar.gz && \
    tar xvzf $mpich_prefix.tar.gz                                           && \
    cd $mpich_prefix                                                        && \
    ./configure                                                             && \
    make -j $ncpus                                                          && \
    make install                                                            && \
    make clean                                                              && \
    cd ..                                                                   && \
    rm -rf $mpich_prefix

RUN /sbin/ldconfig

