22# adapted from https://github.com/Shimwell/openmc_workshop_dependencies
33#
44# Changelog: 1) merge commands to improve performance
5- # 2) add gmsh, ppp, occ_faceter
5+ # 2) add gmsh, ppp, occ_faceter, freecad
66# 3) both X11 and jupyter web interface should be supported
77# 4) ssh server
88# 5) base image can be selected from ubuntu:bionic (18.04), ubuntu:focal (20.04), jupyter/minimal-notebook
99######################################
1010#
1111# build with the following command
1212# sudo docker build -f Dockerfile_ppp_openmc -t ppp_openmc . --no-cache
13- # build from github source seems possible to cache ( build without --no-cache) if start quickly enough
14- # use --no-cache if you know there is no error in this Dockerfile
13+ # build without `--no-cache` can help recover build from where error happened if start quickly enough,
14+ # useful when modify this Dockerfile. The drawback is lots of disk space will be used during trial-and-error process,
15+ # It needs to reclaim by docker command afterwards.
16+ # use --no-cache if you know there is no error in this Dockerfile, to save disk space
1517# USAGE: see README.md
1618################################################
1719
1820
1921# jupyter/minimal-notebook is based on ubuntu-focal, so FROM ubuntu:focal should be working
22+ # if you do not want jupyter-notebook, you can base on ubuntu:focal
2023FROM jupyter/minimal-notebook
2124#FROM ubuntu:focal
22- #FROM ubuntu:bionic
25+
26+
27+ # only last CMD is working, if multiple CMD exists, interactive mode also suppress this CMD
28+ # jupyter can create a terminal, just like ssh
29+ # uncomment this CMD if the base image is not jupyter, assuming ssh server installation section is kept
30+ #CMD ["/usr/sbin/sshd","-D"]
31+
2332
2433LABEL name="ppp_openmc" \
2534 maintainer="qingfeng.xia @ UKAEA" \
@@ -28,11 +37,11 @@ LABEL name="ppp_openmc" \
2837
2938
3039ENV DEBIAN_FRONTEND=noninteractive
31- #ENV OS_ID=`awk '/DISTRIB_ID=/' /etc/os-release | sed 's/DISTRIB_ID=//;' `
32- #ENV OS_VERSION=`awk '/VERSION_ID=/' /etc/*-release | sed 's/VERSION_ID=//' | sed 's/\"//' | sed 's/\"$//' `
3340
3441
35- # this can be override by providing environment variable on docker command line
42+ # for local X11 forwarding, this env var gives a default value
43+ # this can be overridden to another DISPLAY value
44+ # by providing environment variable on docker command line `-e DISPLAY=xxx`
3645ENV DISPLAY :0
3746
3847# this is required to install programs on the base image
@@ -43,53 +52,63 @@ RUN apt-get --yes update && apt-get --yes upgrade
4352# sudo is needed as the install NJOY script has a sudo make install command
4453RUN apt-get -y install sudo git g++ cmake build-essential wget software-properties-common
4554
46- ################## if not using jupyter base docker image ########
55+ #########################################
56+ ## if not using jupyter base docker image
57+ #########################################
58+ # pip install is used later, but pip3 is not installed on ubuntu base images
59+ # this alias makes sure pip and pip3 are same
4760RUN if test "$NB_UID" = "" ; then \
4861 apt install -y python3 python3-pip python3-matplotlib python3-numpy && \
4962 apt-get --yes update && \
5063 ln -s /usr/bin/pip3 /usr/bin/pip && \
5164 ln -s /usr/bin/python3 /usr/bin/python; \
5265 fi
53- ########################################
66+ ########################################################
5467
68+ ######################
69+ ## ubuntu:bionic only
70+ #####################
5571# newer CMake version (3.12) allows us to set libraries, includes of the imported DAGMC target in CMake
56- # pip install is used in some of the travis scripts but pip3 is installed, this alias makes pip and pip3 the same
57- ###################### ubuntu:bionic only ################
72+ # for ubuntu foal, cmake version is high enough, freecad 0.18 is in focal repository
5873RUN if test $(awk '/VERSION_ID=/' /etc/*-release | sed 's/VERSION_ID=//' | sed 's/\"//' | sed 's/\"$//' ) = "18.04" ; then \
5974 add-apt-repository ppa:freecad-maintainers/freecad-stable && \
6075 apt remove -y cmake && \
6176 pip3 install cmake==3.12; \
62- fi
63- ######################################
77+ fi
78+ ##########################################################
79+
6480
65- # install full QT software stack, to make sure matplotlib working with X11 forwording,
66- # it is not needed as freecad will be installed
81+ ##########################
82+ install QT and full graphic software stack
83+ ##########################
84+ # install full QT software stack, to make sure matplotlib working with X11 forwarding,
85+ # it is not needed if freecad will be installed
6786# RUN apt install -y python3-pyside2.qtgui
6887
69- # why non-root user is needed, because jupyter base image is used, put all files in user home
70- # this environment is jupyter/minimal specific
88+ # add apt option --no-recommended to
89+ RUN apt update && apt install freecad -y --no-install-recommends
90+
91+
92+
93+ # why non-root user is needed? because jupyter base image is used, put all files in user home
94+ # this environment is jupyter/minimal specific
7195# ARG NB_USER="jovyan"
7296# see https://github.com/jupyter/docker-stacks/blob/master/base-notebook/Dockerfile
97+ # if built on ubuntu:focal, build with -e NB_USER=root
7398USER $NB_USER
7499
75- ###################### dependancies for openmc ###################
100+ ###################### dependencies for openmc, maob, dagmc ###################
76101# OpenMC required packages identified from openmc travis.yml
77102# libnetcdf-dev is needed to allow NETCDF on MOAB which helps with tet meshes in OpenMC
78- # RUN apt-get --yes install imagemagick hdf5-tools
79103RUN apt-get --yes install imagemagick hdf5-tools mpich libmpich-dev libhdf5-serial-dev libhdf5-mpich-dev libblas-dev liblapack-dev libnetcdf-dev libeigen3-dev
80104
81105
106+ ##################################################################
82107# MOAB Variables
83108ENV MOAB_BRANCH='Version5.1.0'
84109ENV MOAB_REPO='https://bitbucket.org/fathomteam/moab/'
85110ENV MOAB_INSTALL_DIR=$HOME/MOAB/
86111
87-
88- # DAGMC Variables
89- ENV DAGMC_BRANCH='develop'
90- ENV DAGMC_REPO='https://github.com/svalinn/dagmc'
91- ENV DAGMC_INSTALL_DIR=$HOME/DAGMC/
92-
93112# MOAB Install
94113RUN cd $HOME && \
95114 mkdir MOAB && \
@@ -103,6 +122,12 @@ RUN cd $HOME && \
103122 make -j$(nproc) && make install && \
104123 rm -rf $HOME/MOAB/moab $HOME/MOAB/build
105124
125+ ####################################################################
126+ # DAGMC Variables
127+ ENV DAGMC_BRANCH='develop'
128+ ENV DAGMC_REPO='https://github.com/svalinn/dagmc'
129+ ENV DAGMC_INSTALL_DIR=$HOME/DAGMC/
130+
106131# DAGMC Install
107132RUN cd $HOME && \
108133 mkdir DAGMC && cd DAGMC && \
@@ -114,68 +139,85 @@ RUN cd $HOME && \
114139 rm -rf $HOME/DAGMC/dagmc $HOME/DAGMC/build
115140
116141
117- # /opt folder is owned by root
118- USER root
142+ ###############################################
143+ # Clone and install NJOY2016
144+ RUN cd $HOME && git clone https://github.com/njoy/NJOY2016 && \
145+ cd NJOY2016 && mkdir build && cd build && \
146+ cmake -Dstatic=on .. && \
147+ make 2>/dev/null && \
148+ sudo make install && \
149+ cd .. && rm -rf build
119150
120151
152+ ###################### OpenMC ##########################
153+ # /opt folder is owned by root
154+ USER root
121155
122- RUN pip install --upgrade numpy matplotlib pyside2 pyansys
156+ # numpy is needed by openmc-python
157+ RUN pip install --upgrade numpy matplotlib pyside2
123158
124- # openmc must be installed to default location /usr/local/
125- # so cmake have OpenMCConfig.cmake, which is under /usr/local/lib/cmake/OpenMC
126- # installs OpenMC from source (latest), if using jupyter
159+ # openmc should be installed to default location /usr/local/
160+ # so cmake can find OpenMCConfig.cmake, which is under /usr/local/lib/cmake/OpenMC
161+ # installs OpenMC from source (latest)
127162RUN cd /opt && git clone https://github.com/openmc-dev/openmc.git && \
128163 cd /opt/openmc && git checkout develop && \
129164 cd /opt/openmc && mkdir build && \
130165 cd /opt/openmc/build && cmake -Ddagmc=ON -DDAGMC_ROOT=$DAGMC_INSTALL_DIR -DHDF5_PREFER_PARALLEL=OFF -DCMAKE_INSTALL_PREFIX=.. .. && \
131166 cd /opt/openmc/build && make -j$(nproc) && \
132167 cd /opt/openmc/build && make install
133168
169+ # build and install python interface for openmc
134170RUN cd /opt/openmc/ && python setup.py install && \
135171 cd .. && rm -rf build
136172
173+ ## some python package is needed for openmc
174+ RUN pip install neutronics_material_maker --user
137175
138- # Clone and install NJOY2016
139- RUN cd $HOME && git clone https://github.com/njoy/NJOY2016 && \
140- cd NJOY2016 && mkdir build && cd build && \
141- cmake -Dstatic=on .. && \
142- make 2>/dev/null && \
143- sudo make install && \
144- cd .. && rm -rf build
176+ # Oct 2020, openmc must be installed to /opt/openmc, to install this parametric-plasma-source
177+ RUN pip install git+https://github.com/open-radiation-sources/parametric-plasma-source.git
145178
146179
180+ ## to make sure openmc etc are on path for jupyter notebook
147181ENV LD_LIBRARY_PATH=$HOME/MOAB/lib:$HOME/DAGMC/lib
148182ENV PATH=$PATH:$HOME/MOAB/bin:/opt/openmc/bin:$HOME/DAGMC/bin
149183
150- RUN pip install git+https://github.com/open-radiation-sources/parametric-plasma-source.git
151-
152- # no recommended
153- RUN apt update && apt install freecad -y
154184
155- ####### install ssh server #####
185+ ####################
186+ install ssh server
187+ ####################
156188RUN apt install openssh-server nano -y
157189
190+ # to enable X11 forwarding via ssh
158191RUN echo "ForwardX11 yes" >> /etc/ssh/ssh_config && echo "ForwardX11Trusted no" >> /etc/ssh/ssh_config
159192
160- # change UID from 1000 to 1001, as 1000 has been used by another user
193+ # use UID 1001, as 1000 has been used by another user
161194RUN useradd -rm -d /home/ubuntu -s /bin/bash -g root -G sudo -u 1001 test
162195
196+ # set password for the user test as "test"
163197RUN echo 'test:test' | chpasswd
164198RUN service ssh start
165199
166- # only last CMD is working, if mutple CMD exists, interactive mode also suppress this
167- # jupyter can create a terminal, just like ssh, so there is no needed to install ssh
168- # uncomment this CMD is the base image is not jupyter
169- #CMD ["/usr/sbin/sshd","-D"]
170-
200+ # expose port, the default
171201EXPOSE 22
202+ ##################
203+
172204
173- ################### ppp ######################
205+ ##############
206+ ## install gmsh and pygmsh
207+ ##############
208+ RUN apt-get install -y gmsh python3-gmsh
209+ RUN pip install pygmsh
174210
175- # install PPP & occ faceter, ubuntu 18.04 needs PPA to install occt and freecad
211+ ############################################
212+ ## install dependencies for PPP & occ_faceter
213+ #############################################
214+
215+ # ubuntu 18.04 needs PPA to install occt and freecad
176216# occ_faceter needs libcgal-dev,
177- RUN apt-get install -y libocct*-dev occt* python3-dev pybind11-dev libtbb-dev libboost-dev libx11-dev libxmu-dev libxi-dev libcgal-dev gmsh
217+ RUN apt-get install -y libocct*-dev occt* python3-dev pybind11-dev libtbb-dev libboost-dev libx11-dev libxmu-dev libxi-dev libcgal-dev
218+
178219
220+ ## install occ_faceter
179221RUN cd $HOME && git clone https://github.com/makeclean/occ_faceter.git && \
180222 cd occ_faceter && \
181223 mkdir build && cd build && \
@@ -186,6 +228,7 @@ RUN cd $HOME && git clone https://github.com/makeclean/occ_faceter.git && \
186228 make install && \
187229 cd .. && rm -rf build
188230
231+ ## install parallel-preprocessor
189232RUN cd $HOME && git clone https://github.com/ukaea/parallel-preprocessor.git && \
190233 cd parallel-preprocessor && git submodule update --init --recursive && \
191234 mkdir build && cd build && \
@@ -194,38 +237,38 @@ RUN cd $HOME && git clone https://github.com/ukaea/parallel-preprocessor.git &&
194237 make install && \
195238 cd .. && rm -rf build
196239
197- ################## nuclear material data for openmc #########################
198- # install endf nuclear data, this could be skipped and use volume map instead
199- # must mapped to /mat_dir
240+ ##################
241+ ## nuclear material data for openmc
242+ ###################
243+ # consider to split the docker image from here
244+ # copy data into docker image could be skipped and use volume map instead
245+ # but host folder must be mapped to /mat_dir in the container
200246
201- # installed on host, copy into container
247+ # installed on host, the copy into container
202248COPY tendl-2019-hdf5 /mat_dir
203249
204250ENV MAT_DIR=/mat_dir
205251ENV OPENMC_CROSS_SECTIONS=$MAT_DIR/cross_sections.xml
206252
253+ ## another way to install material is
207254# clone data repository
208- RUN cd $HOME && git clone https://github.com/openmc-dev/data.git
209-
255+ # RUN cd $HOME && git clone https://github.com/openmc-dev/data.git
210256# run script that converts ACE data to hdf5 data
211257#RUN python data/convert_nndc71.py --cleanup
212258
213259
214260################# openmc workshop ###################
215- # for jupyter to work:
216261
262+ # for jupyter to work: switch to USER $NB_USER
217263USER $NB_USER
218264
219265RUN git clone -b develop https://github.com/ukaea/openmc_workshop
220266# currently there is some bug stop install parametric_plasma_source
221267#RUN cd openmc_workshop && pip install -r requirements.txt
222268
223- # some python package is needed for openmc
224- RUN pip install neutronics_material_maker --user
225-
226-
227269# can WORKDIR be override by command line option yes, by -w argument
228270WORKDIR openmc_workshop/tasks
229271
230- RUN pip install --upgrade vtk pyansys --user
272+ ###################### some extra tools ###########################
273+ RUN pip install --upgrade vtk pyansys --user
231274
0 commit comments