Skip to content

Commit

Permalink
Merge pull request #3317 from agriyakhetarpal/docker-dependencies
Browse files Browse the repository at this point in the history
Add and update dependencies for Docker images
  • Loading branch information
Saransh-cpp authored Nov 17, 2023
2 parents e0aaaf2 + 172b1f4 commit 1a38b25
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 23 deletions.
14 changes: 8 additions & 6 deletions docs/source/user_guide/installation/install-from-docker.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,21 @@ Install from source (Docker)

.. contents::

This page describes the build and installation of PyBaMM from the source code, available on GitHub. Note that this is **not the recommended approach for most users** and should be reserved to people wanting to participate in the development of PyBaMM, or people who really need to use bleeding-edge feature(s) not yet available in the latest released version. If you do not fall in the two previous categories, you would be better off installing PyBaMM using pip or conda.
This page describes the build and installation of PyBaMM using a Dockerfile, available on GitHub. Note that this is **not the recommended approach for most users** and should be reserved to people wanting to participate in the development of PyBaMM, or people who really need to use bleeding-edge feature(s) not yet available in the latest released version. If you do not fall in the two previous categories, you would be better off installing PyBaMM using ``pip`` or ``conda``.

Prerequisites
-------------

Before you begin, make sure you have Docker installed on your system. You can download and install Docker from the official `Docker website <https://www.docker.com/get-started/>`_.
Ensure Docker installation by running :
Ensure Docker installation by running:

.. code:: bash
docker --version
Pulling the Docker image
------------------------

Use the following command to pull the PyBaMM Docker image from Docker Hub:

.. tab:: No optional solver
Expand Down Expand Up @@ -135,8 +137,8 @@ If you want to build the PyBaMM Docker image locally from the PyBaMM source code
conda activate pybamm
Building Docker images with optional args
-----------------------------------------
Building Docker images with optional arguments
----------------------------------------------

When building the PyBaMM Docker images locally, you have the option to include specific solvers by using optional arguments. These solvers include:

Expand Down Expand Up @@ -190,7 +192,7 @@ If you want to exit the Docker container's shell, you can simply type:
exit
Using Git Inside a Running Docker Container
Using Git inside a running Docker container
-------------------------------------------

.. note::
Expand All @@ -215,7 +217,7 @@ Using Git Inside a Running Docker Container
git fetch --all
Using Visual Studio Code Inside a Running Docker Container
Using Visual Studio Code inside a running Docker container
----------------------------------------------------------

You can easily use Visual Studio Code inside a running Docker container by attaching it directly. This provides a seamless development environment within the container. Here's how:
Expand Down
38 changes: 21 additions & 17 deletions scripts/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ WORKDIR /

# Install the necessary dependencies
RUN apt-get update && apt-get -y upgrade
RUN apt-get install -y libopenblas-dev gcc gfortran graphviz git make g++ build-essential cmake
RUN apt-get install -y libopenblas-dev gcc gfortran graphviz git make g++ build-essential cmake pandoc texlive-latex-extra dvipng
RUN rm -rf /var/lib/apt/lists/*

RUN useradd -m -s /bin/bash pybamm
Expand All @@ -21,45 +21,49 @@ ENV CMAKE_C_COMPILER=/usr/bin/gcc
ENV CMAKE_CXX_COMPILER=/usr/bin/g++
ENV CMAKE_MAKE_PROGRAM=/usr/bin/make
ENV SUNDIALS_INST=/home/pybamm/.local
ENV LD_LIBRARY_PATH=/home/pybamm/.local/lib:
ENV LD_LIBRARY_PATH=/home/pybamm/.local/lib

RUN conda create -n pybamm python=3.11
RUN conda init --all
SHELL ["conda", "run", "-n", "pybamm", "/bin/bash", "-c"]
RUN conda install -y pip

ARG IDAKLU
ARG ODES
ARG JAX
ARG ALL

RUN conda create -n pybamm python=3.9
RUN conda init --all
SHELL ["conda", "run", "-n", "pybamm", "/bin/bash", "-c"]
RUN conda install -y pip
RUN pip install --upgrade --user pip setuptools wheel wget
RUN pip install cmake

RUN if [ "$IDAKLU" = "true" ]; then \
pip install --upgrade --user pip setuptools wheel wget && \
pip install cmake==3.22 && \
python scripts/install_KLU_Sundials.py && \
rm -rf pybind11 && \
git clone https://github.com/pybind/pybind11.git && \
pip install --user -e ".[all,dev]"; \
pip install --user -e ".[all,dev,docs]"; \
fi

RUN if [ "$ODES" = "true" ]; then \
pip install cmake==3.22 && \
pip install --upgrade --user pip wget && \
python scripts/install_KLU_Sundials.py && \
pip install --user -e ".[all,odes,dev]"; \
pip install --user -e ".[all,dev,docs,odes]"; \
fi

RUN if [ "$JAX" = "true" ]; then \
pip install --user -e ".[jax,all,dev]";\
pip install --user -e ".[all,dev,docs,jax]"; \
fi

RUN if [ "$ALL" = "true" ]; then \
pip install cmake==3.22 && \
pip install --upgrade --user pip setuptools wheel wget && \
python scripts/install_KLU_Sundials.py && \
rm -rf pybind11 && \
git clone https://github.com/pybind/pybind11.git && \
pip install --user -e ".[all,dev,jax,odes]"; \
pip install --user -e ".[all,dev,docs,jax,odes]"; \
fi

RUN pip install --user -e ".[all,dev]"
RUN if [ -z "$IDAKLU" ] \
&& [ -z "$ODES" ] \
&& [ -z "$JAX" ] \
&& [ -z "$ALL" ]; then \
pip install --user -e ".[all,dev,docs]"; \
fi

ENTRYPOINT ["/bin/bash"]

0 comments on commit 1a38b25

Please sign in to comment.