Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerize devito application #558

Merged
merged 1 commit into from May 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 25 additions & 2 deletions README.md
Expand Up @@ -31,14 +31,30 @@ provided at the download links. You will need the Python 3.6 version.

To install Devito, including examples, tests and tutorial notebooks,
follow these simple passes:
```

```sh
git clone https://github.com/opesci/devito.git
cd devito
conda env create -f environment.yml
source activate devito
pip install -e .
```

Alternatively, you can also install and run Devito via
[Docker](https://www.docker.com/):

```sh
# get the code
git clone https://github.com/opesci/devito.git
cd devito

# run the tests
docker-compose run devito /tests

# start a jupyter notebook server on port 8888
docker-compose up devito
```

## Examples

At the core of the Devito API are the so-called `Operator` objects, which
Expand Down Expand Up @@ -80,11 +96,18 @@ Thread parallel execution via OpenMP can also be enabled by setting

For the full list of available environment variables and their
possible values, simply run:
```

```py
from devito import print_defaults
print_defaults()
```

Or with Docker, run:

```sh
docker-compose run devito /print-defaults
```

## Performance optimizations

Devito supports two classes of performance optimizations, which are essential
Expand Down
21 changes: 21 additions & 0 deletions docker-compose.yml
@@ -0,0 +1,21 @@
version: '2'

services:

devito:

build:
context: .
dockerfile: docker/Dockerfile

environment:
DEVITO_ARCH: gcc-4.9
DEVITO_OPENMP: 0

volumes:
- ./devito:/app/devito
- ./tests:/app/tests
- ./examples:/app/examples

ports:
- 8888:8888
32 changes: 32 additions & 0 deletions docker/Dockerfile
@@ -0,0 +1,32 @@
FROM python:3.6

ADD ./requirements.txt /app/requirements.txt

RUN python3 -m venv /venv && \
/venv/bin/pip install --no-cache-dir --upgrade pip && \
/venv/bin/pip install --no-cache-dir jupyter && \
/venv/bin/pip install --no-cache-dir -r /app/requirements.txt

ADD ./devito /app/devito
ADD ./tests /app/tests
ADD ./examples /app/examples

ADD docker/run-jupyter.sh /jupyter
ADD docker/run-tests.sh /tests
ADD docker/run-print-defaults.sh /print-defaults
ADD docker/entrypoint.sh /docker-entrypoint.sh

RUN chmod +x \
/print-defaults \
/jupyter \
/tests \
/docker-entrypoint.sh

WORKDIR /app

ENV DEVITO_ARCH="gcc-4.9"
ENV DEVITO_OPENMP="0"

EXPOSE 8888
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["/jupyter"]
5 changes: 5 additions & 0 deletions docker/entrypoint.sh
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

find /app -type f -name '*.pyc' -delete

exec "$@"
3 changes: 3 additions & 0 deletions docker/run-jupyter.sh
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

PYTHONPATH=/app /venv/bin/jupyter notebook --ip=0.0.0.0 --port=8888 --allow-root
6 changes: 6 additions & 0 deletions docker/run-print-defaults.sh
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

PYTHONPATH=/app /venv/bin/python -c "
from devito import print_defaults;
print_defaults();
"
3 changes: 3 additions & 0 deletions docker/run-tests.sh
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

PYTHONPATH=/app /venv/bin/python -m pytest tests/