Skip to content

Commit aab76ec

Browse files
authored
Merge pull request #98 from DavideBaroliUniLu/dbaroli/docker2
add dockerfile; update README; update travis.ylm
2 parents e2fa701 + 3e897b8 commit aab76ec

File tree

4 files changed

+142
-4
lines changed

4 files changed

+142
-4
lines changed

.travis.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
1+
sudo: true
2+
dist: trusty
3+
24
language: python
35

6+
service: docker
7+
48
matrix:
59
include:
610
- os: linux
@@ -43,7 +47,7 @@ install:
4347
conda create --yes -n test python="2.7";
4448
fi
4549
- source activate test
46-
- conda install --yes numpy scipy matplotlib pip nose vtk
50+
- conda install --yes numpy scipy matplotlib pip nose vtk sip=4.18
4751
- conda install --yes -c https://conda.anaconda.org/dlr-sc pythonocc-core
4852
- pip install setuptools
4953
- pip install enum34
@@ -52,8 +56,12 @@ install:
5256
- pip install coverage
5357
- python setup.py install
5458

55-
script: coverage run test.py
56-
59+
script:
60+
- coverage run test.py
61+
# Docker in travis works only with linux.
62+
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
63+
docker run -u root docker.io/pygemdocker/pygem:latest /bin/sh -c "cd /home/PyGeM/build/PyGeM; coverage run test.py";
64+
fi
5765
after_success:
5866
- coveralls
5967

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,34 @@ To uninstall the package you have to rerun the installation and record the insta
5757
> python setup.py install --record installed_files.txt
5858
> cat installed_files.txt | xargs rm -rf
5959
```
60+
Alternatively, a way to run the PyGeM library is to use our prebuilt and high-performance Docker images.
61+
Docker containers are extremely lightweight, secure, and are based on open standards that run on all major Linux distributions, macOS and Microsoft Windows platforms.
6062

63+
Install Docker for your platform by following [these instructions](https://docs.docker.com/engine/getstarted/step_one/).
64+
If using the Docker Toolbox (macOS versions < 10.10 or Windows versions < 10), make sure you run all commands inside the Docker Quickstart Terminal.
65+
66+
Now we will pull the docker.io/pygemdocker/pygem image from our cloud infrastructure:
67+
```bash
68+
> docker pull docker.io/pygemdocker/pygem:latest
69+
```
70+
Docker will pull the latest tag of the image pygemdocker/pygem from docker.io. The download is around 3.246 GB. The image is a great place to start experimenting with PyGeM and includes all dependencies already compiled for you.
71+
Once the download is complete you can start PyGeM for the first time. Just run:
72+
```bash
73+
> docker run -ti pygemdocker/pygem:latest
74+
```
75+
To facilitate the devoloping, using the text editor,version control and other tools already installed on your computers,
76+
it is possible to share files from the host into the container:
77+
78+
```bash
79+
> docker run -ti -v $(pwd):/home/PyGeM/shared pygemdocker/pygem:latest
80+
```
81+
To allow the X11 forwarding in the container, on Linux system just run:
82+
83+
```bash
84+
> docker run -ti --rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v $(pwd):/home/PyGeM/shared pygemdocker/pygem:latest
85+
```
86+
87+
For Windows system, you need to install Cygwin/X version and running the command in Cygwin terminal. While for mac system, you need to install xquartz.
6188

6289
## Documentation
6390
**PyGeM** uses [Sphinx](http://www.sphinx-doc.org/en/stable/) for code documentation. To build the html versions of the docs simply:

dockerfiles/Dockerfile

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
FROM phusion/baseimage:0.9.19
2+
3+
# Get Ubuntu updates
4+
USER root
5+
RUN apt-get update -q && \
6+
apt-get upgrade -y -o Dpkg::Options::="--force-confold" && \
7+
apt-get -y install sudo && \
8+
apt-get -y install locales && \
9+
echo "C.UTF-8 UTF-8" > /etc/locale.gen && \
10+
locale-gen && \
11+
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
12+
13+
# Set locale environment
14+
ENV LC_ALL=C.UTF-8 \
15+
LANG=C.UTF-8 \
16+
LANGUAGE=C.UTF-8
17+
18+
# OpenBLAS threads should be 1 to ensure performance
19+
RUN echo 1 > /etc/container_environment/OPENBLAS_NUM_THREADS && \
20+
echo 0 > /etc/container_environment/OPENBLAS_VERBOSE
21+
22+
23+
# Set up user so that we do not run as root
24+
RUN useradd -m -s /bin/bash -G sudo,docker_env PyGeM && \
25+
echo "PyGeM:docker" | chpasswd && \
26+
echo "PyGeM ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
27+
28+
RUN touch /etc/service/syslog-forwarder/down
29+
COPY set-home-permissions.sh /etc/my_init.d/set-home-permissions.sh
30+
RUN chmod +x /etc/my_init.d/set-home-permissions.sh
31+
32+
USER PyGeM
33+
ENV HOME /home/PyGeM
34+
RUN touch $HOME/.sudo_as_admin_successful && \
35+
mkdir $HOME/shared && \
36+
mkdir $HOME/build
37+
VOLUME /home/PyGeM/shared
38+
39+
WORKDIR /home/PyGeM
40+
ENTRYPOINT ["sudo","/sbin/my_init","--quiet","--","sudo","-u","PyGeM","/bin/bash","-l","-c"]
41+
CMD ["/bin/bash","-i"]
42+
43+
# utilities and libraries
44+
USER root
45+
RUN apt-get update -y; apt-get install -y --force-yes --fix-missing --no-install-recommends curl git unzip tree subversion vim cmake bison g++ gfortran openmpi-bin pkg-config wget libpcre3-dev bison flex swig libglu1-mesa pyqt4-dev-tools
46+
RUN apt-get clean && \
47+
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
48+
49+
RUN id PyGeM
50+
RUN chown -R PyGeM:PyGeM $HOME
51+
52+
RUN cd /tmp && \
53+
wget https://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh && \
54+
chmod +x miniconda.sh && \
55+
bash miniconda.sh -b -p /usr/local/miniconda && \
56+
rm /tmp/*
57+
ENV PATH=/usr/local/miniconda/bin:$PATH
58+
59+
RUN echo "PATH=/usr/local/miniconda/bin:$PATH" >> ~/.profile
60+
RUN /bin/bash -c 'source ~/.profile'
61+
62+
RUN hash -r && \
63+
conda config --set always_yes yes --set changeps1 no && \
64+
conda update -q conda
65+
RUN conda info -a && \
66+
conda create --yes -n test python="2.7";
67+
68+
RUN /bin/bash -c 'source activate test'
69+
# The default sip version has api that is not compatible with qt4.
70+
RUN conda install --yes numpy scipy matplotlib pip nose vtk sip=4.18
71+
RUN conda install --yes -c https://conda.anaconda.org/dlr-sc pythonocc-core &&\
72+
pip install setuptools && \
73+
pip install enum34 && \
74+
pip install numpy-stl && \
75+
pip install coveralls && \
76+
pip install coverage
77+
78+
RUN cd $HOME && \
79+
cd build && \
80+
git clone https://github.com/mathLab/PyGeM.git && \
81+
cd PyGeM && \
82+
python setup.py install
83+
84+
USER PyGeM
85+
86+

dockerfiles/set-home-permissions.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
# User can pass e.g. --env HOST_UID=1003 so that UID in the container matches
3+
# with the UID on the host. This is useful for Linux users, Mac and Windows
4+
# already do transparent mapping of shared volumes.
5+
if [ "$HOST_UID" ]; then
6+
usermod -u $HOST_UID PyGeM
7+
fi
8+
if [ "$HOST_GID" ]; then
9+
groupmod -g $HOST_GID PyGeM
10+
fi
11+
# This makes sure that all files in /home/fenics are accessible by the user
12+
# fenics. We exclude the folder ~/shared to reduce IO out to the host. Docker
13+
# for Mac, Docker for Windows and the UID/GID trick above should mean that file
14+
# permissions work seamlessly now.
15+
cd /home/PyGeM
16+
find . -maxdepth 1 | grep -v "./shared" | xargs chown -R PyGeM:PyGeM
17+

0 commit comments

Comments
 (0)