diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..c29e1321c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,39 @@ +FROM ubuntu:latest + +# Setup environment variables for Docker image +ENV FC=/usr/bin/mpif90 CC=/usr/bin/mpicc CXX=/usr/bin/mpicxx \ + PATH=/opt/openmc/bin:/opt/NJOY2016/build:$PATH \ + LD_LIBRARY_PATH=/opt/openmc/lib:$LD_LIBRARY_PATH \ + OPENMC_CROSS_SECTIONS=/root/nndc_hdf5/cross_sections.xml \ + OPENMC_MULTIPOLE_LIBRARY=/root/WMP_Library \ + OPENMC_ENDF_DATA=/root/endf-b-vii.1 + +# Install dependencies from Debian package manager +RUN apt-get update -y && \ + apt-get upgrade -y && \ + apt-get install -y python3-pip && \ + apt-get install -y wget git emacs && \ + apt-get install -y gfortran g++ cmake && \ + apt-get install -y mpich libmpich-dev && \ + apt-get install -y libhdf5-serial-dev libhdf5-mpich-dev && \ + apt-get install -y imagemagick && \ + apt-get autoremove + +# Update system-provided pip +RUN pip3 install --upgrade pip + +# Clone and install NJOY2016 +RUN git clone https://github.com/njoy/NJOY2016 /opt/NJOY2016 && \ + cd /opt/NJOY2016 && \ + mkdir build && cd build && \ + cmake -Dstatic=on .. && make 2>/dev/null && make install + +# Clone and install OpenMC +RUN git clone https://github.com/openmc-dev/openmc.git /opt/openmc && \ + cd /opt/openmc && mkdir -p build && cd build && \ + cmake -Doptimize=on -DHDF5_PREFER_PARALLEL=on .. && \ + make && make install && \ + cd .. && pip install -e .[test] + +# Download cross sections (NNDC and WMP) and ENDF data needed by test suite +RUN ./opt/openmc/tools/ci/download-xs.sh \ No newline at end of file diff --git a/docs/source/devguide/docker.rst b/docs/source/devguide/docker.rst new file mode 100644 index 000000000..12c095c45 --- /dev/null +++ b/docs/source/devguide/docker.rst @@ -0,0 +1,57 @@ +.. _devguide_docker: + +====================== +Deployment with Docker +====================== + +OpenMC can be easily deployed using `Docker `_ on any +Windows, Mac or Linux system. With Docker running, execute the following +command in the shell to build a `Docker image`_ called ``debian/openmc:latest``: + +.. code-block:: sh + + docker build -t debian/openmc:latest https://github.com/openmc-dev/openmc.git#develop + +.. note:: This may take 5 -- 10 minutes to run to completion. + +This command will execute the instructions in OpenMC's ``Dockerfile`` to +build a Docker image with OpenMC installed. The image includes OpenMC with +MPICH and parallel HDF5 in the ``/opt/openmc`` directory, and +`Miniconda3 `_ with all of the Python +pre-requisites (NumPy, SciPy, Pandas, etc.) installed. The +`NJOY2016 `_ codebase is installed in +``/opt/NJOY2016`` to support full functionality and testing of the +``openmc.data`` Python module. The publicly available nuclear data libraries +necessary to run OpenMC's test suite -- including NNDC and WMP cross sections +and ENDF data -- are in the ``/opt/openmc/data directory``, and the +corresponding :envvar:`OPENMC_CROSS_SECTIONS`, +:envvar:`OPENMC_MULTIPOLE_LIBRARY`, and :envvar:`OPENMC_ENDF_DATA` +environment variables are initialized. + +After building the Docker image, you can run the following to see the names of +all images on your machine, including ``debian/openmc:latest``: + +.. code-block:: sh + + docker image ls + +Now you can run the following to create a `Docker container`_ called +``my_openmc`` based on the ``debian/openmc:latest`` image: + +.. code-block:: sh + + docker run -it --name=my_openmc debian/openmc:latest + +This command will open an interactive shell running from within the +Docker container where you have access to use OpenMC. + +.. note:: The ``docker run`` command supports many + `options `_ + for spawning containers -- including `mounting volumes`_ from the + host filesystem -- which many users will find useful. + +.. _Docker image: https://docs.docker.com/engine/reference/commandline/images/ +.. _Docker container: https://www.docker.com/resources/what-container +.. _options: https://docs.docker.com/engine/reference/commandline/run/ +.. _mounting volumes: https://docs.docker.com/storage/volumes/ + diff --git a/docs/source/devguide/index.rst b/docs/source/devguide/index.rst index e2410f080..d100fdcdf 100644 --- a/docs/source/devguide/index.rst +++ b/docs/source/devguide/index.rst @@ -18,3 +18,4 @@ other related topics. tests user-input docbuild + docker diff --git a/docs/source/quickinstall.rst b/docs/source/quickinstall.rst index 731bffde7..37e431f55 100644 --- a/docs/source/quickinstall.rst +++ b/docs/source/quickinstall.rst @@ -58,6 +58,29 @@ are no longer supported. .. _Personal Package Archive: https://launchpad.net/~paulromano/+archive/staging .. _APT package manager: https://help.ubuntu.com/community/AptGet/Howto +------------------------------------------- +Installing on Linux/Mac/Windows with Docker +------------------------------------------- + +OpenMC can be easily deployed using `Docker `_ on any +Windows, Mac or Linux system. With Docker running, execute the following +command in the shell to download and run a `Docker image`_ with the most recent release of OpenMC from `DockerHub `_ called ``openmc/openmc:v0.10.0``: + +.. code-block:: sh + + docker run openmc/openmc:v0.10.0 + +This will take several minutes to run depending on your internet download speed. The command will place you in an interactive shell running in a `Docker container`_ with OpenMC installed. + +.. note:: The ``docker run`` command supports many `options`_ for spawning + containers -- including `mounting volumes`_ from the host + filesystem -- which many users will find useful. + +.. _Docker image: https://docs.docker.com/engine/reference/commandline/images/ +.. _Docker container: https://www.docker.com/resources/what-container +.. _options: https://docs.docker.com/engine/reference/commandline/run/ +.. _mounting volumes: https://docs.docker.com/storage/volumes/ + --------------------------------------- Installing from Source on Ubuntu 15.04+ --------------------------------------- diff --git a/tools/ci/download-xs.sh b/tools/ci/download-xs.sh new file mode 100755 index 000000000..5ac270090 --- /dev/null +++ b/tools/ci/download-xs.sh @@ -0,0 +1,19 @@ +#!/bin/bash +set -ex + +# Download NNDC HDF5 data +if [[ ! -e $HOME/nndc_hdf5/cross_sections.xml ]]; then + wget https://anl.box.com/shared/static/a0eflty17atnpd0pp7460exagr3nuhm7.xz -O - | tar -C $HOME -xvJ +fi + +# Download ENDF/B-VII.1 distribution +ENDF=$HOME/endf-b-vii.1/ +if [[ ! -d $ENDF/neutrons || ! -d $ENDF/photoat || ! -d $ENDF/atomic_relax ]]; then + wget https://anl.box.com/shared/static/4kd2gxnf4gtk4w1c8eua5fsua22kvgjb.xz -O - | tar -C $HOME -xvJ +fi + +# Download multipole library +if [[ ! -e $HOME/WMP_Library/092235.h5 ]]; then + wget https://github.com/mit-crpg/WMP_Library/releases/download/v1.0/WMP_Library_v1.0.tar.gz + tar -C $HOME -xzvf WMP_Library_v1.0.tar.gz +fi diff --git a/tools/ci/travis-before-script.sh b/tools/ci/travis-before-script.sh index f267cb020..c810a4a4d 100755 --- a/tools/ci/travis-before-script.sh +++ b/tools/ci/travis-before-script.sh @@ -5,19 +5,5 @@ set -ex # https://docs.travis-ci.com/user/gui-and-headless-browsers/#Using-xvfb-to-Run-Tests-That-Require-a-GUI sh -e /etc/init.d/xvfb start -# Download NNDC HDF5 data -if [[ ! -e $HOME/nndc_hdf5/cross_sections.xml ]]; then - wget https://anl.box.com/shared/static/a0eflty17atnpd0pp7460exagr3nuhm7.xz -O - | tar -C $HOME -xvJ -fi - -# Download ENDF/B-VII.1 distribution -ENDF=$HOME/endf-b-vii.1/ -if [[ ! -d $ENDF/neutrons || ! -d $ENDF/photoat || ! -d $ENDF/atomic_relax ]]; then - wget https://anl.box.com/shared/static/4kd2gxnf4gtk4w1c8eua5fsua22kvgjb.xz -O - | tar -C $HOME -xvJ -fi - -# Download multipole library -if [[ ! -e $HOME/WMP_Library/092235.h5 ]]; then - wget https://github.com/mit-crpg/WMP_Library/releases/download/v1.0/WMP_Library_v1.0.tar.gz - tar -C $HOME -xzvf WMP_Library_v1.0.tar.gz -fi +# Download NNDC HDF5 data, ENDF/B-VII.1 distribution, multipole library +sh ./tools/ci/download-xs.sh