From 7400a756e688045d5ffb23f7117e2d6745963839 Mon Sep 17 00:00:00 2001
From: Lambert Theisen <lambert.theisen@rwth-aachen.de>
Date: Wed, 30 Oct 2024 16:23:20 +0100
Subject: [PATCH] Add Docker setup and document it in Readme (for macOS)

---
 Dockerfile         | 20 ++++++++++++++++++++
 README.md          | 13 ++++++++++---
 docker-compose.yml | 10 ++++++++++
 3 files changed, 40 insertions(+), 3 deletions(-)
 create mode 100644 Dockerfile
 create mode 100644 docker-compose.yml

diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..3000a1a
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,20 @@
+# Start with a base image that includes conda
+FROM continuumio/miniconda3
+
+# Set environment variables
+ENV CONDA_DEFAULT_ENV=fenicsx-env
+ENV PATH /opt/conda/envs/${CONDA_DEFAULT_ENV}/bin:$PATH
+ENV HOME /root
+
+# Create the environment and install packages
+RUN conda create --name ${CONDA_DEFAULT_ENV} python=3.12.3 -y && \
+    conda install -n ${CONDA_DEFAULT_ENV} -c conda-forge fenics-dolfinx=0.8.0 mpich=4.2.1 pyvista=0.43.10 matplotlib=3.8.4 numpy=1.26.4 scipy=1.14.0 gcc=12.4.0 sphinx=7.3.7 myst-parser=4.0.0 sphinx-copybutton=0.5.2 sphinx-rtd-theme=3.0.1 -y
+
+# Activate environment
+SHELL ["conda", "run", "-n", "fenicsx-env", "/bin/bash", "-c"]
+
+WORKDIR /root
+
+# Set the default environment on container start
+# ENTRYPOINT ["conda", "run", "-n", "fenicsx-env", "/bin/bash", "-c"]
+CMD ["bash"]
diff --git a/README.md b/README.md
index 6db1fc4..712d0c4 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
 # Reproducibility Repository for Numerical Treatment of a Thermodynamically Consistent Electrolyte Model (B.Sc. Thesis - Jan Habscheid)
 
-[![Pipeline Status](https://git.rwth-aachen.de/Jan.Habscheid/bsc-electrolytemodels/badges/main/pipeline.svg)](https://git.rwth-aachen.de/Jan.Habscheid/bsc-electrolytemodels/pipelines) 
+[![Pipeline Status](https://git.rwth-aachen.de/Jan.Habscheid/bsc-electrolytemodels/badges/main/pipeline.svg)](https://git.rwth-aachen.de/Jan.Habscheid/bsc-electrolytemodels/pipelines)
 [![Documentation](https://img.shields.io/badge/docs-latest-blue)](https://janhab.pages.rwth-aachen.de/bsc-electrolytemodels/)
 [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.13645296.svg)](https://doi.org/10.5281/zenodo.13645296)
 [![GitLab Version](https://img.shields.io/badge/version-1.0-blue.svg)](https://git.rwth-aachen.de/jan.habscheid/bsc-electrolytemodels/-/tags)
@@ -40,9 +40,16 @@ Use the "environment.yml" file to install all necessary environments
 conda env create -f environment.yml
 ```
 
+### macOS installation using Docker
+
+```
+docker compose build
+docker compose run solver
+```
+
 ## Usage
 
-Find the visualizations from the thesis and some extra calculations in the "examples" folder. 
+Find the visualizations from the thesis and some extra calculations in the "examples" folder.
 In the subfolder "ReproducableCode" is the code, to execute the calculations with some first visualizations.
 The subfolder "Data" stores the data for all the simulations in a *.npz file, which can be read with numpy `np.load(file.npz)`.
 "Visualizations" creates the necessary figures from the thesis and stores them in *.svg format in "Figures".
@@ -66,4 +73,4 @@ In "src" there are the generic FEniCSx implementations, that were used to calcul
 - Prof. Dr. Manuel Torrilhon
 - ACoM - Applied and Computational Mathematics
 - RWTH Aachen University
-- mt@acom.rwth-aachen.de
\ No newline at end of file
+- mt@acom.rwth-aachen.de
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..e8645b3
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,10 @@
+services:
+  solver:
+    build:
+      context: .
+      dockerfile: Dockerfile
+    volumes:
+      - .:/root/solver
+    stdin_open: true  # Equivalent to -i for interactive mode
+    tty: true         # Equivalent to -t for a terminal interface
+    command: ["/bin/bash"]
-- 
GitLab