CarpetX: a Cactus driver for the Einstein Toolkit based on AMReX
# How to build this Docker image:
#     docker build . --tag eschnett/cactus-amrex
#     docker push eschnett/cactus-amrex

# Use NixOS
FROM nixos/nix

# RUN nix-channel --add https://nixos.org/channels/nixpkgs-unstable nixpkgs
# RUN nix-channel --update

# RUN nix-build -A pythonFull '<nixpkgs>'
RUN nix-env -i \
        cmake \
        gfortran-wrapper \
        git \
        gnumake \
        gsl \
        hwloc \
        mpich \
        perl \
        pkg-config \
        python \
        python3 \
        rsync \
        subversion \
        wget \
        zlib

RUN mkdir /cactus
WORKDIR /cactus

# # Install system packages
# RUN apt-get update && \
#     apt-get --yes --no-install-recommends install \
#         build-essential \
#         ca-certificates \
#         g++ \
#         gfortran \
#         git \
#         libgsl-dev \
#         libhwloc-dev \
#         libmpich-dev \
#         perl \
#         pkg-config \
#         python \
#         python3 \
#         rsync \
#         subversion \
#         wget \
#         zlib1g-dev \
#         && \
#     rm -rf /var/lib/apt/lists/*

# Install AMReX
RUN mkdir src
WORKDIR /cactus/src
RUN wget https://github.com/AMReX-Codes/amrex/archive/20.01.tar.gz
RUN tar xzf 20.01.tar.gz
WORKDIR /cactus/src/amrex-20.01
RUN mkdir build
WORKDIR /cactus/src/amrex-20.01/build
RUN cmake -DCMAKE_BUILD_TYPE=Debug -DENABLE_PARTICLES=ON -DENABLE_ASSERTIONS=ON -DENABLE_BACKTRACE=ON -DENABLE_OMP=ON -DCMAKE_INSTALL_PREFIX=/cactus/amrex ..
RUN make -j$(nproc)
RUN make -j$(nproc) install
WORKDIR /cactus
# RUN rm -rf src

# As documentation
COPY Dockerfile /Dockerfile