Skip to content

Commit

Permalink
Change firedrake and SeismicMesh versions in Dockerfile. The test_gra…
Browse files Browse the repository at this point in the history
…dient_2D.py is now working (if the absolute errors are used
  • Loading branch information
SouzaEM committed Jun 24, 2024
1 parent f97931b commit e8cb6c8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 30 deletions.
19 changes: 5 additions & 14 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM firedrakeproject/firedrake:2024-05 AS spyro_base
FROM firedrakeproject/firedrake:2023-09 AS spyro_base

USER root
RUN apt-get update \
Expand All @@ -16,28 +16,19 @@ RUN . /home/firedrake/firedrake/bin/activate; pip3 install segyio

# spyro dependencies
USER root
# Is there a reason for using development versions?
RUN apt-get update && apt-get install -y libgmp3-dev libmpfr-dev libcgal-dev python3-tk
USER firedrake
RUN . /home/firedrake/firedrake/bin/activate; pip3 install --no-dependencies SeismicMesh[io]
# The PyPI SeismicMesh has bugs. It is better to install from GitHub
RUN . /home/firedrake/firedrake/bin/activate; pip3 install --no-dependencies git+https://github.com/krober10nd/SeismicMesh.git
RUN . /home/firedrake/firedrake/bin/activate; pip3 install pyamg
RUN . /home/firedrake/firedrake/bin/activate; pip3 install meshio

FROM spyro_base AS spyro_release

RUN . /home/firedrake/firedrake/bin/activate; pip install git+https://github.com/Olender/spyro-1.git

FROM spyro_base AS spyro_test_base
FROM spyro_base AS spyro_development

RUN . /home/firedrake/firedrake/bin/activate; pip3 install pytest

WORKDIR /home/firedrake

FROM spyro_test_base AS spyro_test

RUN git clone https://github.com/Olender/spyro-1.git
WORKDIR /home/firedrake/spyro-1/test

FROM spyro_test_base AS spyro_development

RUN echo "/home/firedrake/shared/" >> /home/firedrake/firedrake/lib/python3.10/site-packages/shared.pth
RUN echo "/home/firedrake/shared/spyro" >> /home/firedrake/firedrake/lib/python3.10/site-packages/shared.pth
30 changes: 14 additions & 16 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
## Docker images

This directory presents a Dockerfile to provide images for release (user installation), and development/testing. The release image comes with the corresponding spyro version installed, while the development/testing image use the current spyro checkout. The latest spyro version is not installed in the development/testing image to avoid ambiguities during use.

The build commands below assume that the working directory is the root of spyro. If your current working directory is different, you have to adjust the Dockerfile path.

### Installing

The Docker image may be used for installing spyro. The following command builds the release image:
````
docker build -t runtag:1.0 --target spyro_release .
docker build -t runtag:1.0 --target spyro_release docker
````

Then, the following commands gives access to a virtual environment with spyro:
Expand All @@ -13,30 +17,24 @@ docker run -it runtag:1.0
. firedrake/bin/activate
````

### Testing

The Docker image for running the tests is built with the following command (considering that your working directory is the same where the Dockerfile is located):
````
docker build -t testtag:1.0 --target spyro_test .
````

Then, the following command may be called for running the tests:
````
docker run -it testtag:1.0 /bin/bash -c "source /home/firedrake/firedrake/bin/activate; python3 -m pytest --maxfail=1 ."
````

### Development
### Development/Testing

The Dockerfile may also be used to create a development environment. First, clone the git repository and then build the development image:
````
git clone https://github.com/Olender/spyro-1.git
cd spyro-1
git checkout <your_branch>
docker build -t devtag:1.0 -f docker/Dockerfile --target spyro_development .
docker build -t devtag:1.0 -f docker/Dockerfile --target spyro_development docker
````

Then, start a container and share your local repository:
````
docker run -v $PWD/spyro:/home/firedrake/shared/spyro -it devtag:1.0
docker run -v $PWD:/home/firedrake/shared/spyro -it devtag:1.0
. firedrake/bin/activate
````

For running the automated tests:
````
cd shared/spyro/
python3 -m pytest --maxfail=1 test/
````

0 comments on commit e8cb6c8

Please sign in to comment.