From ae9b3d7ea816534d59ffc458018923bfbb0ac6c1 Mon Sep 17 00:00:00 2001 From: Eduardo Moscatelli de Souza <5752216+SouzaEM@users.noreply.github.com> Date: Tue, 7 May 2024 11:35:14 -0300 Subject: [PATCH 1/5] Add first version of Dockerfile with release image --- docker/Dockerfile | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 docker/Dockerfile diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 00000000..c2ad4ccd --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,28 @@ +FROM firedrakeproject/firedrake:2024-05 AS spyro_base + +USER root +RUN apt-get update \ + && apt-get -y dist-upgrade \ + && apt-get -y install gmsh patchelf \ + && rm -rf /var/lib/apt/lists/* + +USER firedrake +RUN . /home/firedrake/firedrake/bin/activate; pip3 install wheel --upgrade +RUN . /home/firedrake/firedrake/bin/activate; pip3 install scipy +RUN . /home/firedrake/firedrake/bin/activate; pip3 install roltrilinos +RUN . /home/firedrake/firedrake/bin/activate; pip3 install ROL + +# 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 +USER firedrake +RUN . /home/firedrake/firedrake/bin/activate; pip3 install matplotlib +RUN . /home/firedrake/firedrake/bin/activate; pip3 install segyio +RUN . /home/firedrake/firedrake/bin/activate; pip3 install --no-dependencies SeismicMesh[io] +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 5dadc1978f64b3f5a1d4c9adfa27fca2e023286d Mon Sep 17 00:00:00 2001 From: Eduardo Moscatelli de Souza <5752216+SouzaEM@users.noreply.github.com> Date: Tue, 7 May 2024 14:21:39 -0300 Subject: [PATCH 2/5] Add testing environment to Docker images --- docker/Dockerfile | 13 +++++++++++-- docker/README.md | 24 ++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 docker/README.md diff --git a/docker/Dockerfile b/docker/Dockerfile index c2ad4ccd..996712ff 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -11,14 +11,14 @@ RUN . /home/firedrake/firedrake/bin/activate; pip3 install wheel --upgrade RUN . /home/firedrake/firedrake/bin/activate; pip3 install scipy RUN . /home/firedrake/firedrake/bin/activate; pip3 install roltrilinos RUN . /home/firedrake/firedrake/bin/activate; pip3 install ROL +RUN . /home/firedrake/firedrake/bin/activate; pip3 install matplotlib +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 USER firedrake -RUN . /home/firedrake/firedrake/bin/activate; pip3 install matplotlib -RUN . /home/firedrake/firedrake/bin/activate; pip3 install segyio RUN . /home/firedrake/firedrake/bin/activate; pip3 install --no-dependencies SeismicMesh[io] RUN . /home/firedrake/firedrake/bin/activate; pip3 install pyamg RUN . /home/firedrake/firedrake/bin/activate; pip3 install meshio @@ -26,3 +26,12 @@ 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 + +RUN . /home/firedrake/firedrake/bin/activate; pip3 install pytest + +WORKDIR /home/firedrake +RUN git clone https://github.com/Olender/spyro-1.git + +WORKDIR /home/firedrake/spyro-1/test diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 00000000..1154820d --- /dev/null +++ b/docker/README.md @@ -0,0 +1,24 @@ +### 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 . +```` + +Then, the following commands gives access to a virtual environment with spyro: +```` +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 ." +```` \ No newline at end of file From 4707465f0c2acd9c2e2abdea4bc62b3d623b3c68 Mon Sep 17 00:00:00 2001 From: Eduardo Moscatelli de Souza <5752216+SouzaEM@users.noreply.github.com> Date: Tue, 7 May 2024 17:21:06 -0300 Subject: [PATCH 3/5] Add development environment to Docker images --- docker/Dockerfile | 10 ++++++++-- docker/README.md | 20 +++++++++++++++++++- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 996712ff..f89df040 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -27,11 +27,17 @@ 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 +FROM spyro_base AS spyro_test_base RUN . /home/firedrake/firedrake/bin/activate; pip3 install pytest WORKDIR /home/firedrake -RUN git clone https://github.com/Olender/spyro-1.git +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 diff --git a/docker/README.md b/docker/README.md index 1154820d..1f665ecd 100644 --- a/docker/README.md +++ b/docker/README.md @@ -1,3 +1,5 @@ +## Docker images + ### Installing The Docker image may be used for installing spyro. The following command builds the release image: @@ -21,4 +23,20 @@ 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 ." -```` \ No newline at end of file +```` + +### Development + +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 +docker build -t devtag:1.0 -f docker/Dockerfile --target spyro_development . +```` + +Then, start a container and share your local repository: +```` +docker run -v $PWD/spyro:/home/firedrake/firedrake -it devtag:1.0 +. firedrake/bin/activate +```` From f97931b83f535677471d2a03b1b703d76c1b5c1a Mon Sep 17 00:00:00 2001 From: Eduardo Moscatelli de Souza <5752216+SouzaEM@users.noreply.github.com> Date: Fri, 7 Jun 2024 10:03:08 -0300 Subject: [PATCH 4/5] Add python3-tk to enable visualization with the container and fix instruction to mount the working copy to the container --- docker/Dockerfile | 2 +- docker/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index f89df040..dcbef67f 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -17,7 +17,7 @@ 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 +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] RUN . /home/firedrake/firedrake/bin/activate; pip3 install pyamg diff --git a/docker/README.md b/docker/README.md index 1f665ecd..4ea4aac4 100644 --- a/docker/README.md +++ b/docker/README.md @@ -37,6 +37,6 @@ docker build -t devtag:1.0 -f docker/Dockerfile --target spyro_development . Then, start a container and share your local repository: ```` -docker run -v $PWD/spyro:/home/firedrake/firedrake -it devtag:1.0 +docker run -v $PWD/spyro:/home/firedrake/shared/spyro -it devtag:1.0 . firedrake/bin/activate ```` From e8cb6c88884030bb32634b507776ad5ed4826030 Mon Sep 17 00:00:00 2001 From: Eduardo Moscatelli de Souza <5752216+SouzaEM@users.noreply.github.com> Date: Mon, 24 Jun 2024 10:34:08 -0300 Subject: [PATCH 5/5] Change firedrake and SeismicMesh versions in Dockerfile. The test_gradient_2D.py is now working (if the absolute errors are used --- docker/Dockerfile | 19 +++++-------------- docker/README.md | 30 ++++++++++++++---------------- 2 files changed, 19 insertions(+), 30 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index dcbef67f..0f1c6380 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -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 \ @@ -16,10 +16,10 @@ 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 @@ -27,17 +27,8 @@ 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 diff --git a/docker/README.md b/docker/README.md index 4ea4aac4..d61c861d 100644 --- a/docker/README.md +++ b/docker/README.md @@ -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: @@ -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 -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/ +````