diff --git a/.github/workflows/dockerhub-publish-dagmc.yml b/.github/workflows/dockerhub-publish-dagmc.yml new file mode 100644 index 000000000..d96229279 --- /dev/null +++ b/.github/workflows/dockerhub-publish-dagmc.yml @@ -0,0 +1,35 @@ +name: dockerhub-publish-latest-dagmc + +on: + push: + branches: master + +jobs: + main: + runs-on: ubuntu-latest + steps: + - + name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - + name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Build and push + id: docker_build + uses: docker/build-push-action@v2 + with: + push: true + tags: openmc/openmc:latest-dagmc + build-args: | + include_dagmc=true + compile_cores=2 + - + name: Image digest + run: echo ${{ steps.docker_build.outputs.digest }} diff --git a/.github/workflows/dockerhub-publish-dev.yml b/.github/workflows/dockerhub-publish-dev.yml index 00fab4129..73f62acaa 100644 --- a/.github/workflows/dockerhub-publish-dev.yml +++ b/.github/workflows/dockerhub-publish-dev.yml @@ -27,6 +27,8 @@ jobs: with: push: true tags: openmc/openmc:develop + build-args: | + compile_cores=2 - name: Image digest run: echo ${{ steps.docker_build.outputs.digest }} diff --git a/.github/workflows/dockerhub-publish-release-dagmc.yml b/.github/workflows/dockerhub-publish-release-dagmc.yml new file mode 100644 index 000000000..6038a9878 --- /dev/null +++ b/.github/workflows/dockerhub-publish-release-dagmc.yml @@ -0,0 +1,38 @@ +name: dockerhub-publish-release-dagmc + +on: + push: + tags: 'v*.*.*' + +jobs: + main: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set env + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + - + name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - + name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Build and push + id: docker_build + uses: docker/build-push-action@v2 + with: + push: true + tags: openmc/openmc:${{ env.RELEASE_VERSION }}-dagmc + build-args: | + include_dagmc=true + compile_cores=2 + - + name: Image digest + run: echo ${{ steps.docker_build.outputs.digest }} diff --git a/.github/workflows/dockerhub-publish-release.yml b/.github/workflows/dockerhub-publish-release.yml index d8de72618..c94a50c0d 100644 --- a/.github/workflows/dockerhub-publish-release.yml +++ b/.github/workflows/dockerhub-publish-release.yml @@ -30,6 +30,8 @@ jobs: with: push: true tags: openmc/openmc:${{ env.RELEASE_VERSION }} + build-args: | + compile_cores=2 - name: Image digest run: echo ${{ steps.docker_build.outputs.digest }} diff --git a/.github/workflows/dockerhub-publish.yml b/.github/workflows/dockerhub-publish.yml index 0737849e9..6bd0c4dc6 100644 --- a/.github/workflows/dockerhub-publish.yml +++ b/.github/workflows/dockerhub-publish.yml @@ -27,6 +27,8 @@ jobs: with: push: true tags: openmc/openmc:latest + build-args: | + compile_cores=2 - name: Image digest run: echo ${{ steps.docker_build.outputs.digest }} diff --git a/.github/workflows/name: dockerhub-publish-develop-dagmc.yml b/.github/workflows/name: dockerhub-publish-develop-dagmc.yml new file mode 100644 index 000000000..0ded0c180 --- /dev/null +++ b/.github/workflows/name: dockerhub-publish-develop-dagmc.yml @@ -0,0 +1,35 @@ +name: dockerhub-publish-develop-dagmc + +on: + push: + branches: develop + +jobs: + main: + runs-on: ubuntu-latest + steps: + - + name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - + name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Build and push + id: docker_build + uses: docker/build-push-action@v2 + with: + push: true + tags: openmc/openmc:develop-dagmc + build-args: | + include_dagmc=true + compile_cores=2 + - + name: Image digest + run: echo ${{ steps.docker_build.outputs.digest }} diff --git a/Dockerfile b/Dockerfile index 4d3fdb1e9..325a0f4bd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,20 @@ +# To build with OpenMC +# docker build -t openmc . + +# To build with OpenMC and DAGMC enabled +# docker build -t openmc_dagmc --build-arg include_dagmc=true . + +# To make use of multiple cores during the compile stages of the docker build +# docker build -t openmc_dagmc --build-arg compile_cores=8 . + FROM ubuntu:latest +# By default this Dockerfile builds OpenMC without dagmc +ARG include_dagmc=false + +# By default one core is used to compile +ARG compile_cores=1 + # Setup environment variables for Docker image ENV CC=/usr/bin/mpicc CXX=/usr/bin/mpicxx \ PATH=/opt/openmc/bin:/opt/NJOY2016/build:$PATH \ @@ -26,12 +41,111 @@ RUN git clone https://github.com/njoy/NJOY2016 /opt/NJOY2016 && \ mkdir build && cd build && \ cmake -Dstatic=on .. && make 2>/dev/null && make install -# Clone and install OpenMC -RUN git clone --recurse-submodules 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] +# Clone and install OpenMC without DAGMC +RUN if [ "$include_dagmc" = "false" ] ; \ + then git clone --recurse-submodules 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 -j"$compile_cores" ; \ + make -j"$compile_cores" install ; \ + cd .. ; \ + pip install -e .[test] ; \ + fi + +# install addition packages required for DAGMC +RUN if [ "$include_dagmc" = "true" ] ; \ + then apt-get --yes install libeigen3-dev ; \ + apt-get --yes install libnetcdf-dev ; \ + apt-get --yes install libtbb-dev ; \ + apt-get --yes install libglfw3-dev ; \ + fi + +# Clone and install Embree +RUN if [ "$include_dagmc" = "true" ] ; \ + then git clone https://github.com/embree/embree ; \ + cd embree ; \ + mkdir build ; \ + cd build ; \ + cmake .. -DCMAKE_INSTALL_PREFIX=.. \ + -DEMBREE_ISPC_SUPPORT=OFF ; \ + make -j"$compile_cores" ; \ + make -j"$compile_cores" install ; \ + fi + +# Clone and install MOAB +RUN if [ "$include_dagmc" = "true" ] ; \ + then pip install --upgrade numpy cython ; \ + mkdir MOAB ; \ + cd MOAB ; \ + mkdir build ; \ + git clone --single-branch --branch develop https://bitbucket.org/fathomteam/moab/ ; \ + cd build ; \ + cmake ../moab -DENABLE_HDF5=ON \ + -DENABLE_NETCDF=ON \ + -DBUILD_SHARED_LIBS=OFF \ + -DENABLE_FORTRAN=OFF \ + -DENABLE_BLASLAPACK=OFF ; \ + make -j"$compile_cores" ; \ + make -j"$compile_cores" install ; \ + rm -rf * ; \ + cmake ../moab -DBUILD_SHARED_LIBS=ON \ + -DENABLE_HDF5=ON \ + -DENABLE_PYMOAB=ON \ + -DENABLE_BLASLAPACK=OFF \ + -DENABLE_FORTRAN=OFF \ + -DENABLE_BLASLAPACK=OFF ; \ + make -j"$compile_cores" ; \ + make -j"$compile_cores" install ; \ + fi + +# Clone and install Double-Down +RUN if [ "$include_dagmc" = "true" ] ; \ + then git clone https://github.com/pshriwise/double-down ; \ + cd double-down ; \ + mkdir build ; \ + cd build ; \ + cmake .. -DCMAKE_INSTALL_PREFIX=.. \ + -DMOAB_DIR=/usr/local \ + -DEMBREE_DIR=/embree/lib/cmake/embree-3.12.1 ; \ + make -j"$compile_cores" ; \ + make -j"$compile_cores" install ; \ + fi + +# Clone and install DAGMC +RUN if [ "$include_dagmc" = "true" ] ; \ + then mkdir DAGMC ; \ + cd DAGMC ; \ + git clone -b develop https://github.com/svalinn/dagmc ; \ + mkdir build ; \ + cd build ; \ + cmake ../dagmc -DBUILD_TALLY=ON \ + -DCMAKE_INSTALL_PREFIX=/dagmc/ \ + -DMOAB_DIR=/usr/local \ + -DBUILD_STATIC_LIBS=OFF \ + -DBUILD_STATIC_EXE=OFF ; \ + make -j"$compile_cores" install ; \ + rm -rf /DAGMC/dagmc /DAGMC/build ; \ + fi + +# Clone and install OpenMC with DAGMC +RUN if [ "$include_dagmc" = "true" ] ; \ + then git clone --recurse-submodules https://github.com/openmc-dev/openmc.git /opt/openmc ; \ + cd /opt/openmc ; \ + mkdir build ; \ + cd build ; \ + cmake -Doptimize=on \ + -Ddagmc=ON \ + -DDAGMC_DIR=/DAGMC/ \ + -DHDF5_PREFER_PARALLEL=on .. ; \ + make -j"$compile_cores" ; \ + make -j"$compile_cores" install ; \ + cd .. ; \ + pip install -e .[test] ; \ + fi # Download cross sections (NNDC and WMP) and ENDF data needed by test suite RUN /opt/openmc/tools/ci/download-xs.sh