Skip to content

Commit ba3aa6a

Browse files
author
Weiwei Wang
authored
Merge pull request #52 from fangohr/master
Docker file for fidimag
2 parents 305beed + 06b66b0 commit ba3aa6a

File tree

5 files changed

+158
-1
lines changed

5 files changed

+158
-1
lines changed

bin/ubuntu_install_script.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
sudo bash install.sh
21
sudo bash install-ubuntu-packages.sh
2+
bash install-fftw.sh
3+
bash install-sundials-2.5.sh
34
sudo pip install cython --upgrade
5+
cd ..
46
make
57
echo "export PYTHONPATH=$(dirname $PWD):$PYTHONPATH" >> /home/$USER/.bashrc

install/docker/Dockerfile

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
FROM ubuntu:14.04
2+
3+
# packages we need to run fidimag
4+
RUN apt-get -y update
5+
RUN apt-get -y install python-numpy python-dev python-scipy
6+
RUN apt-get -y install python-pytest python-pyvtk ipython python-matplotlib mayavi2
7+
# standard tools for compilation
8+
RUN apt-get -y install wget make git
9+
10+
# where to install source
11+
ENV FIDIMAG_HOME /home/fidimag
12+
13+
RUN mkdir -p $FIDIMAG_HOME
14+
WORKDIR $FIDIMAG_HOME
15+
RUN git clone https://github.com/computationalmodelling/fidimag.git
16+
WORKDIR $FIDIMAG_HOME/fidimag/bin
17+
18+
# install third party libraries from source
19+
RUN bash install-ubuntu-packages.sh
20+
RUN bash install-fftw.sh
21+
RUN bash install-sundials-2.5.sh
22+
23+
# for pip
24+
RUN apt-get -y install python-pip
25+
# install cython
26+
RUN pip install cython --upgrade
27+
WORKDIR $FIDIMAG_HOME/fidimag
28+
29+
# compile fidimag
30+
RUN make
31+
env PYTHONPATH=$FIDIMAG_HOME/fidimag
32+
env LD_LIBRARY_PATH=$FIDIMAG_HOME/fidimag/local/lib
33+
WORKDIR $FIDIMAG_HOME/fidimag/tests
34+
35+
# check that tests run okay
36+
RUN py.test -v
37+
38+
39+
# install Jupyter, port exposing doesn't work yet
40+
#RUN pip install jupyter
41+
42+
# expose jupyter port - not working yet
43+
#EXPOSE 8888 8888
44+
45+
46+
# Set up user so that we do not run as root
47+
RUN useradd -m -s /bin/bash -G sudo fidimag && \
48+
echo "fidimag:docker" | chpasswd && \
49+
echo "fidimag ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
50+
RUN chown -R fidimag $FIDIMAG_HOME
51+
52+
USER fidimag
53+
RUN touch $FIDIMAG_HOME/.sudo_as_admin_successful
54+
55+
# Print something nice on entry.
56+
#COPY WELCOME $FIDIMAG_HOME/WELCOME
57+
58+
59+
60+
WORKDIR $FIDIMAG_HOME
61+
CMD ["/bin/bash","-i"]

install/docker/Dockerfile.org

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
* How to use
2+
3+
** Linux
4+
5+
$> sudo docker pull fangohr/fidimag
6+
7+
$> docker run -ci fangohr/fidimag ipython
8+
9+
then try 'import fidimag'.
10+
11+
12+
13+
14+

install/docker/Makefile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# to build a new docker image
2+
build:
3+
time docker build -t fangohr/fidimag:latest .
4+
5+
# to run new image
6+
run:
7+
docker run -ti fangohr/fidimag bash
8+
# try 'ipython' and then 'import fidimag'
9+
10+
login:
11+
docker login
12+
13+
# to push the new docker image to dockerhub (need to login first)
14+
push:
15+
docker push fangohr/fidimag:latest
16+
17+
# to fetch image to local machine
18+
pull:
19+
docker pull fangohr/fidimag:latest

install/docker/Readme.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Docker
2+
3+
First steps towards running fidimag through Docker.
4+
5+
## Using the docker container
6+
7+
There is a fidimag container available under `fangohr/fidimag`.
8+
9+
To use it, you can try this:
10+
11+
1. Install docker
12+
13+
2. Pull the container onto your machine using
14+
15+
`docker pull fangohr/fidimag`
16+
17+
3. Start the container using
18+
19+
`docker run -ti fangohr/fidimag`
20+
21+
This command should show a bash prompt inside the docker container:
22+
23+
<pre>
24+
bin:docker fangohr$ docker run -ti fangohr/fidimag
25+
fidimag@38fdd2a0feb4:~$
26+
</pre>
27+
28+
One way to test the installation is to run the unit tests:
29+
30+
<pre>
31+
fidimag@38fdd2a0feb4:~$ cd fidimag/tests/
32+
fidimag@38fdd2a0feb4:~/fidimag/tests$ py.test -v
33+
========== test session starts =======================
34+
platform linux2 -- Python 2.7.6 -- pytest-2.5.1 -- /usr/bin/python
35+
collected 63 items
36+
37+
field_test.py:7: test_initialise_scalar PASSED
38+
field_test.py:13: test_initialise_vector PASSED
39+
test_2dpbc_cube.py:10: test_compute_field PASSED
40+
test_anis.py:7: test_anis PASSED
41+
.
42+
.
43+
.
44+
</pre>
45+
46+
## Shortcomings
47+
48+
- need to share directory between host and container (MOUNT or VOLUME)
49+
50+
- make use of jupyter notebook work (as we have seen in FEniCS course): connect port in container to port on host machine (EXPOSE)
51+
52+
53+
54+
## Creating the docker container
55+
56+
The `Makefile` in this directory shows the relevant targets (build, login, push) to create a new container and push it to the the cloud.
57+
58+
59+
60+
61+

0 commit comments

Comments
 (0)