Skip to content

Commit 6a39fa6

Browse files
authored
Merge pull request #25 from qingfengxia/dev
Dockerfile for centos8 with docker iamge ppp-centos uploaded to dockerhub
2 parents 8e8ac08 + 8a300aa commit 6a39fa6

File tree

5 files changed

+169
-54
lines changed

5 files changed

+169
-54
lines changed

docker/Dockerfile_centos

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# command to build: docker build --rm -f Dockerfile_centos -t qingfengxia/ppp-centos . --no-cache
2+
# docker push qingfengxia/ppp-centos:latest
3+
# Use multi-stage builds: https://docs.docker.com/develop/develop-images/multistage-build/
4+
# rebuild on top of local image (instead of base OS layer) for quick modification, run without `--rm`
5+
# docker build -f Dockerfile_centos -t qingfengxia/ppp-centos .
6+
7+
# Base OS layer:
8+
FROM centos:8
9+
10+
LABEL name="ppp-centos" \
11+
maintainer="qingfeng.xia @ UKAEA" \
12+
version="0.3" \
13+
description="parallel with OpenCASCADE"
14+
15+
#USER root
16+
17+
# avoid interactive timezone selection, ENV setting will affect child image
18+
# ENV TZ=Europe/London
19+
# RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
20+
21+
# using yum command -y
22+
ENV DEBIAN_FRONTEND=noninteractive
23+
24+
# centos-release-scl is only needed for cento 7.6 or lower
25+
# yum install epel-release centos-release-scl -y
26+
# the default cmake version is too low 2.8 for centos7
27+
28+
# you must update before any yum install or add a repo
29+
# dnf group install "Development Tools" -y
30+
RUN yum install epel-release -y && yum update -y && dnf groupinstall "Development Tools" -y \
31+
&& yum install wget cmake git python3 python3-devel -y
32+
33+
34+
RUN yum install tbb tbb-devel freetype freetype-devel fontconfig-devel freeimage freeimage-devel -y
35+
36+
# for OpenCASCADE, openGL is needed for BUILD_MODULE_Visualization, and TKService
37+
RUN yum install libXmu-devel libX11-devel libXi-devel -y
38+
39+
# install those below if Draw module is enabled for building OpenCASCADE
40+
# yum install tk tcl tk-devel tcl-devel -y
41+
42+
# these packages SDL2_image-devel name maybe centos7, or needed by centos7 only
43+
RUN if test $(awk '/VERSION_ID=/' /etc/*-release | sed 's/VERSION_ID=//' | sed 's/\"//' | sed 's/\"$//' ) = "7" ; then \
44+
yum install SDL2-devel glew-devel glm-devel -y; \
45+
fi
46+
47+
# centos8 install fron non-official repo
48+
RUN if test $(awk '/VERSION_ID=/' /etc/*-release | sed 's/VERSION_ID=//' | sed 's/\"//' | sed 's/\"$//' ) = "8" ; then \
49+
dnf --enablerepo=PowerTools install glew-devel glm-devel SDL2-devel -y; \
50+
fi
51+
52+
# install OpenCASCADE from official readonly repo is not working, it needs to upload ssh pubkey
53+
# https://old.opencascade.com/doc/occt-7.0.0/overview/html/occt_dev_guides__git_guide.html
54+
# git clone -b V7_4_0p1 [email protected]:occt occt
55+
56+
RUN cd $HOME && wget "http://git.dev.opencascade.org/gitweb/?p=occt.git;a=snapshot;h=V7_4_0p1;sf=tgz" -O occt.tar.gz && \
57+
tar -xzf occt.tar.gz
58+
59+
RUN cd $HOME && cd occt-* && \
60+
mkdir build && cd build && \
61+
cmake .. -DUSE_TBB=ON -DBUILD_MODULE_Draw=OFF -DBUILD_MODULE_Visualization=OFF && \
62+
make -j$(nproc) && \
63+
make install && \
64+
cd .. && rm -rf build
65+
66+
67+
ENV DISPLAY :0
68+
69+
70+
RUN cd $HOME && git clone https://github.com/ukaea/parallel-preprocessor.git && \
71+
cd parallel-preprocessor && git submodule update --init --recursive && \
72+
mkdir build && cd build && \
73+
dnf install which -y && \
74+
cmake .. -DPYTHON_EXECUTABLE=$(which python3) -DCMAKE_BUILD_TYPE=Release && \
75+
make -j$(nproc) && \
76+
make install && \
77+
cd .. && rm -rf build
78+
79+
# pppGeomPipeline: error while loading shared libraries: libpppGeom.so: cannot open shared object file: No such file or directory
80+
# /usr/local/lib is not system LD path, the solution is below
81+
ENV LD_LIBRARY_PATH=/usr/local/lib

docker/Dockerfile_ppp_openmc

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
# Changelog: 1) merge commands to improve performance
55
# 2) add gmsh, ppp, occ_faceter, freecad
66
# 3) both X11 and jupyter web interface should be supported
7-
# 4) ssh server
8-
# 5) base image can be selected from ubuntu:bionic (18.04), ubuntu:focal (20.04), jupyter/minimal-notebook
7+
# 4) base image can be selected from ubuntu:bionic (18.04), ubuntu:focal (20.04), jupyter/minimal-notebook
98
######################################
109
#
1110
# build with the following command
@@ -26,8 +25,6 @@ FROM jupyter/minimal-notebook
2625

2726
# only last CMD is working, if multiple CMD exists, interactive mode also suppress this CMD
2827
# 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"]
3128

3229

3330
LABEL name="ppp_openmc" \
@@ -171,7 +168,7 @@ RUN cd /opt/openmc/ && python setup.py install && \
171168
cd .. && rm -rf build
172169

173170
## some python package is needed for openmc
174-
RUN pip install neutronics_material_maker --user
171+
RUN pip install neutronics_material_maker
175172

176173
# Oct 2020, openmc must be installed to /opt/openmc, to install this parametric-plasma-source
177174
RUN pip install git+https://github.com/open-radiation-sources/parametric-plasma-source.git
@@ -182,26 +179,6 @@ ENV LD_LIBRARY_PATH=$HOME/MOAB/lib:$HOME/DAGMC/lib
182179
ENV PATH=$PATH:$HOME/MOAB/bin:/opt/openmc/bin:$HOME/DAGMC/bin
183180

184181

185-
####################
186-
install ssh server
187-
####################
188-
RUN apt install openssh-server nano -y
189-
190-
# to enable X11 forwarding via ssh
191-
RUN echo "ForwardX11 yes" >> /etc/ssh/ssh_config && echo "ForwardX11Trusted no" >> /etc/ssh/ssh_config
192-
193-
# use UID 1001, as 1000 has been used by another user
194-
RUN useradd -rm -d /home/ubuntu -s /bin/bash -g root -G sudo -u 1001 test
195-
196-
# set password for the user test as "test"
197-
RUN echo 'test:test' | chpasswd
198-
RUN service ssh start
199-
200-
# expose port, the default
201-
EXPOSE 22
202-
##################
203-
204-
205182
##############
206183
## install gmsh and pygmsh
207184
##############
@@ -262,6 +239,10 @@ ENV OPENMC_CROSS_SECTIONS=$MAT_DIR/cross_sections.xml
262239
# for jupyter to work: switch to USER $NB_USER
263240
USER $NB_USER
264241

242+
# for ssh login user to have path setup
243+
RUN echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/MOAB/lib:$HOME/DAGMC/lib" >> $HOME/.bashrc
244+
RUN echo "export PATH=$PATH:$HOME/MOAB/bin:/opt/openmc/bin:$HOME/DAGMC/bin" >> $HOME/.bashrc
245+
265246
RUN git clone -b develop https://github.com/ukaea/openmc_workshop
266247
# currently there is some bug stop install parametric_plasma_source
267248
#RUN cd openmc_workshop && pip install -r requirements.txt

docker/Dockerfile_ssh

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# this layer add ssh, X11 forwarding, sudo capacity
2+
# it can be based on any image, to add ssh access feature
3+
# mkdir .ssh
4+
# ssh-keygen -b 1024 -t rsa -f .ssh/ssh_host_key_rsa
5+
# build with the following command (in the folder where pubkey has been generated)
6+
# sudo docker build -f Dockerfile_ssh -t ppp_openmc_ssh . --no-cache
7+
8+
# To test ssh X11Forwarding
9+
# 1) client must have been tested to be working with X11 forwarding with other remote ssh server
10+
# debug connection by -v option `ssh -vv -Y -p 2222 [email protected]`
11+
# 2) user root is not usually allowed to do X11 forwarding,
12+
#
13+
# if can not open DISPLAY, check if -X or -Y option has been set in ssh client command
14+
#
15+
# error "X11 forwarding request failed on channel 0"
16+
# solved by adding `X11UseLocalhost no` `X11Forwarding yes` to /etc/ssh/sshd_config
17+
############################################################################
18+
19+
FROM qingfengxia/ppp_openmc
20+
21+
USER root
22+
23+
####################
24+
# install ssh server
25+
####################
26+
RUN apt-get install openssh-server nano -y
27+
28+
################# ssh user ####################
29+
30+
31+
# change password, add to sudo group
32+
RUN echo 'jovyan:test' | chpasswd && usermod -aG sudo $NB_USER
33+
34+
# Allow members of group sudo to execute any command
35+
# TAB key causes some trouble, use more spaces before "ALL=" seems working
36+
RUN echo "%sudo ALL=(ALL:ALL) ALL" >> /etc/sudoers
37+
# if above still not working add this user to /etc/sudoers
38+
#RUN echo "$NB_USER ALL=(ALL:ALL) ALL" >> /etc/sudoers
39+
40+
############### host key setup #################
41+
# https://nickjanetakis.com/blog/docker-tip-56-volume-mounting-ssh-keys-into-a-docker-container
42+
# copy the ssh key from host, so to fix the host public key when rebuilding the image
43+
44+
COPY .ssh /root/.ssh
45+
RUN chmod 700 /root/.ssh && \
46+
chmod 644 /root/.ssh/ssh_host_key_rsa.pub && \
47+
chmod 600 /root/.ssh/ssh_host_key_rsa
48+
49+
RUN cp /root/.ssh/ssh_host_key_rsa.pub /etc/ssh/ && \
50+
cp /root/.ssh/ssh_host_key_rsa /etc/ssh/
51+
52+
# sshd_config has been modified by adding those lines
53+
# to enable X11 forwarding via ssh, by default has been enabled
54+
RUN echo "X11Forwarding yes" >> /etc/ssh/sshd_config && echo "X11UseLocalhost no" >> /etc/ssh/sshd_config
55+
RUN echo "HostKey /etc/ssh/ssh_host_key_rsa" >> /etc/ssh/sshd_config
56+
57+
# expose port, the default port
58+
EXPOSE 22
59+
##################
60+
61+
62+
CMD ["/usr/sbin/sshd", "-D"]
63+
64+
65+
USER $NB_USER

docker/README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Parallel-preprocessor in Docker
22

3-
Since binary packages are available for Ubuntu, fedora and Debian, there is no need to provide Dockerfile on each platforms, but Docker based on centos would be sufficient.
3+
Since binary packages are available for Ubuntu, fedora and Debian, there is no need to provide Dockerfile on each platforms, but only one Docker image based on centos will be maintained
44

5-
## Readme for ppp_centos docker image
5+
## Readme for ppp-centos docker image
66

7-
`docker pull qingfengxia/ppp_centos`
8-
9-
This is should be small image with only occt and ppp; both are compiled from source.
7+
`docker pull qingfengxia/ppp-centos`
8+
This is should be a small image (size 1.6 GB) based on centos8, with only occt (v7.4) and PPP compiled from source.
109

10+
It is designed for any user want to try ppp using docker.
1111

1212
## Readme for ppp_openmc docker image
1313

@@ -17,7 +17,8 @@ Note: this image is large, about 10 GB
1717

1818
## Get the docker image
1919

20-
`docker pull qingfengxia/ppp_openmc`
20+
`docker pull qingfengxia/ppp_openmc` for jupyter notebook way
21+
`docker pull qingfengxia/ppp_openmc_ssh` for jupyter notebook and ssh ways, it is based on image `qingfengxia/ppp_openmc`
2122

2223
https://hub.docker.com/repository/docker/qingfengxia/ppp_openmc
2324

@@ -27,7 +28,7 @@ The docker image is based on `jupyter/mini-notebook` , but it can be switched to
2728

2829
## Use this image
2930

30-
There are 3 ways to use this docker image, choose the one you like
31+
There are 3 ways to use these docker images, choose the one you like
3132

3233
### 1. The jupyter notebook way
3334

@@ -44,7 +45,7 @@ https://jupyter-docker-stacks.readthedocs.io/en/latest/using/common.html
4445

4546
> -e GRANT_SUDO=yes - Instructs the startup script to grant the NB_USER user passwordless sudo capability. You do not need this option to allow the user to conda or pip install additional packages. This option is useful, however, when you wish to give $NB_USER the ability to install OS packages with apt or modify other root-owned files in the container. For this option to take effect, you must run the container with --user root. (The start-notebook.sh script will su $NB_USER after adding $NB_USER to sudoers.) You should only enable sudo if you trust the user or if the container is running on an isolated host.
4647
47-
### 2. X11 forwarding on local machine
48+
### 2. X11 forwarding on local Linux host machine (deprecated as X11 via SSH is more convenient)
4849

4950
to get an interative bash shell, as ubuntu 20.04
5051

@@ -68,24 +69,24 @@ See https://medium.com/@l10nn/running-x11-applications-with-docker-75133178d090
6869

6970
### 3. SSH remote shell
7071
SSH has also X11 forwarding turned on
71-
`docker run --rm -p 2222:22 -e GRANT_SUDO=yes --user root -it ppp_openmc bash ` then start the ssh server by `sudo service ssh start `
72+
`docker run --rm -p 2222:22 -p 8888:8888 -e GRANT_SUDO=yes --user root -it ppp_openmc_ssh bash ` then start the ssh server by `sudo service ssh start `
7273

7374
This argument `-p 2222:22` map container's port 22 to host 2222 port.
74-
To access this container by ssh:
75-
either `ssh localhost -p 2222` or `ssh <container_ip> -p 22`
75+
To access this container by ssh (-v means verbose, -Y means X11 forwarding):
76+
either `ssh -v -Y localhost -p 2222` or `ssh -v -Y <container_ip> -p 22`
7677

7778
see also [How to setup an ssh server within a docker container](https://phoenixnap.com/kb/how-to-ssh-into-docker-container)
7879
rebuild the image will change ssh server public key, as the ssh server installation will generate new key pair each time.
7980

80-
#### user name and password for ssh both “test”
81+
#### user name is "jovyan" and password is “test”
8182

8283
On Ubuntu, install the `sshpass` package, then use it like this: `sshpass -p 'YourPassword' ssh user@host`
8384

8485
#### start ssh server automatically
8586

86-
Automatically start the ssh server is possible by uncomment `CMD ["/usr/sbin/sshd","-D"]` in Dockerfile if **Rebuild with ubuntu:focal as the base image**.
87+
Automatically start the ssh server is possible by `CMD ["/usr/sbin/sshd","-D"]` in Dockerfile_ssh, if the docker container is running non-interactively (without -it option)
8788

88-
Currently, `CMD ["/usr/sbin/sshd","-D"]` is commented out, because it will override the jupyter’s start_notebook CMD.
89+
In Dockerfile_ssh, the line `CMD ["/usr/sbin/sshd","-D"]` will override the jupyter’s start_notebook CMD.
8990

9091
> Multiple CMD commands: In principle, there should only be one CMD command in your Dockerfile. When CMD is used multiple times, only the last instance is executed.
9192
https://www.educative.io/edpresso/what-is-the-cmd-command-in-docker
@@ -94,7 +95,6 @@ Currently, `CMD ["/usr/sbin/sshd","-D"]` is commented out, because it will over
9495
### Rebuild with ubuntu:focal as the base image
9596
change in Dockerfile before build:
9697
1) FROM ubuntu:focal
97-
2) uncomment `CMD ["/usr/sbin/sshd","-D"]`
9898
Then build with command line,
9999
`sudo docker build -f -e NB_USER=root Dockerfile_ppp_openmc -t ppp_openmc . --no-cache`
100100

wiki/BuildOnLinux.md

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -170,19 +170,7 @@ yum install opencascade-draw, opencascade-foundation, opencascade-modeling, op
170170

171171
#### Option 2: Download the opencascade source code and compile from source.
172172

173-
if not in package repository
174-
175-
```bash
176-
###### dependencies needed to build OpenCASCADE from source ##########
177-
# for OpenCASCADE, openGL is needed
178-
yum install tbb tbb-devel freetype freetype-devel freeimage freeimage-devel -y \
179-
&& yum install libXmu-devel libXi-devel glew-devel SDL2-devel SDL2_image-devel glm-devel -y
180-
# install those below if draw module is enabled for building OpenCASCADE
181-
yum install tk tcl tk-devel tcl-devel -y
182-
183-
# package name distinguish capital letter, while debian name is just libxmu
184-
yum install openmpi-devel boost-devel -y
185-
```
173+
Compile opencascade if not available in package repository, e.g. centos 7/8, see the "Dockerfile_centos" file for updated instructions.
186174

187175
To get the latest source code from [OCCT official website](https://www.opencascade.com/), you need register (free of charge). Registered user may setup public ssh key and get readonly access to the occt repo
188176
`git clone -b V7_4_0p1 [email protected]:occt occt`
@@ -200,7 +188,7 @@ tar -xzf occt.tar.gz
200188
cd occt-*
201189
mkdir build
202190
cd build
203-
cmake ..
191+
cmake .. -DUSE_TBB=ON -DBUILD_MODULE_Draw=OFF
204192
make -j$(nproc)
205193
sudo make install
206194
# by default install to the prefix: /usr/local/

0 commit comments

Comments
 (0)