From 242d41b21aab68757ef265f7be699c0555f9c3b9 Mon Sep 17 00:00:00 2001
From: Joseph Weston <joseph@weston.cloud>
Date: Wed, 28 Nov 2018 14:50:55 +0100
Subject: [PATCH] add Dockerfiles and conda environment files for testing Kwant

---
 docker/Dockerfile.conda           | 20 ++++++++++++
 docker/Dockerfile.debian          | 30 ++++++++++++++++++
 docker/Dockerfile.ubuntu          | 28 +++++++++++++++++
 docker/README.rst                 | 52 +++++++++++++++++++++++++++++++
 docker/kwant-latest.yml           | 29 +++++++++++++++++
 docker/kwant-stable-no-extras.yml | 26 ++++++++++++++++
 docker/kwant-stable.yml           | 29 +++++++++++++++++
 7 files changed, 214 insertions(+)
 create mode 100644 docker/Dockerfile.conda
 create mode 100644 docker/Dockerfile.debian
 create mode 100644 docker/Dockerfile.ubuntu
 create mode 100644 docker/README.rst
 create mode 100644 docker/kwant-latest.yml
 create mode 100644 docker/kwant-stable-no-extras.yml
 create mode 100644 docker/kwant-stable.yml

diff --git a/docker/Dockerfile.conda b/docker/Dockerfile.conda
new file mode 100644
index 00000000..dc2b0b31
--- /dev/null
+++ b/docker/Dockerfile.conda
@@ -0,0 +1,20 @@
+FROM conda/miniconda3:latest
+
+ENV LANG C.UTF-8
+ENV LC_ALL C.UTF-8
+
+RUN apt-get update && apt-get install -y --no-install-recommends \
+        # all the hard non-Python dependencies
+        git make patch build-essential \
+        # Additional tools for running CI
+        file rsync openssh-client \
+        # Documentation building
+        inkscape texlive-full zip \
+    && apt-get clean && \
+    rm -rf /var/lib/apt/lists/*
+
+COPY kwant-latest.yml kwant-stable.yml kwant-stable-no-extras.yml /
+
+RUN conda env create -qf kwant-stable.yml
+RUN conda env create -qf kwant-stable-no-extras.yml
+RUN conda env create -qf kwant-latest.yml
diff --git a/docker/Dockerfile.debian b/docker/Dockerfile.debian
new file mode 100644
index 00000000..de47cca8
--- /dev/null
+++ b/docker/Dockerfile.debian
@@ -0,0 +1,30 @@
+FROM debian:latest
+
+ENV LANG C.UTF-8
+ENV LC_ALL C.UTF-8
+
+RUN apt-get update && apt-get install -y --no-install-recommends \
+        gnupg dirmngr apt-transport-https ca-certificates curl software-properties-common
+
+RUN echo "deb http://downloads.kwant-project.org/debian/ stretch-backports main" >> /etc/apt/sources.list && \
+    apt-key adv --no-tty --keyserver pool.sks-keyservers.net --recv-key C3F147F5980F3535 && \
+    apt-get update && apt-get install -y --no-install-recommends \
+        # all the hard non-Python dependencies
+        git g++ make patch gfortran libblas-dev liblapack-dev \
+        libmumps-scotch-dev pkg-config libfreetype6-dev \
+        # all the hard Python dependencies
+        python3-all-dev python3-setuptools python3-pip python3-tk python3-wheel \
+        python3-numpy python3-scipy python3-matplotlib python3-sympy python3-tinyarray \
+        # Additional tools for running CI
+        file rsync openssh-client \
+    && apt-get clean && \
+    rm -rf /var/lib/apt/lists/*
+
+### install build and testing dependencies
+RUN pip3 install \
+      cython \
+      pytest \
+      pytest-runner \
+      pytest-cov \
+      pytest-flakes \
+      pytest-pep8
diff --git a/docker/Dockerfile.ubuntu b/docker/Dockerfile.ubuntu
new file mode 100644
index 00000000..85434711
--- /dev/null
+++ b/docker/Dockerfile.ubuntu
@@ -0,0 +1,28 @@
+FROM ubuntu:16.04
+
+ENV LANG C.UTF-8
+ENV LC_ALL C.UTF-8
+
+RUN apt-get update && apt-get install -y --no-install-recommends \
+        gnupg dirmngr apt-transport-https software-properties-common
+RUN apt-add-repository -s ppa:kwant-project/ppa && \
+    apt-get update && apt-get install -y --no-install-recommends \
+        # all the hard non-Python dependencies
+        git g++ make patch gfortran libblas-dev liblapack-dev \
+        libmumps-scotch-dev pkg-config libfreetype6-dev \
+        # all the hard Python dependencies
+        python3-all-dev python3-setuptools python3-pip python3-tk python3-wheel \
+        python3-numpy python3-scipy python3-matplotlib python3-sympy python3-tinyarray \
+        # Additional tools for running CI
+        file rsync openssh-client \
+    && apt-get clean && \
+    rm -rf /var/lib/apt/lists/*
+
+### install build and testing dependencies
+RUN pip3 install \
+      cython \
+      pytest \
+      pytest-runner \
+      pytest-cov \
+      pytest-flakes \
+      pytest-pep8
diff --git a/docker/README.rst b/docker/README.rst
new file mode 100644
index 00000000..e348bf7e
--- /dev/null
+++ b/docker/README.rst
@@ -0,0 +1,52 @@
+====================
+Kwant Testing Images
+====================
+This directory contains files for building Docker images used in
+testing Kwant. The Dockerfile for a given platforms can also
+be understood as recipes for how to install the prerequesites of
+Kwant on that platform. To build an image it is enough to execute::
+
+    docker build -f <dockerfile>
+
+from this directory (where ``<dockerfile>`` should be replaced with the
+filename of the appropriate dockerfile to build).
+
+Dockerfiles
+===========
+
+Dockerfile.debian
+  Builds an environment based on Debian stable. Python 3 and all the dependencies
+  of Kwant are installed using the Debian repositories. Includes all optional
+  dependencies (for plotting and the continuum module).
+
+Dockerfile.ubuntu
+  Builds an environment based on the latest Ubuntu LTS release that is supported
+  by Kwant (we typically wait until 6 months after a new LTS release to upgrade
+  Kwant's requirements, to give people time to switch). Python 3 and
+  all the dependencies of Kwant are installed using the Ubuntu repositories.
+  Includes all optional dependencies (for plotting and the continuum module).
+
+Dockerfile.conda
+  Builds an environment that contains Miniconda and a minimal number of
+  system-installed packages (mainly to make Git and documentation building work).
+  Individual testing environments are installed as conda environments (see
+  the next section for details).
+
+Conda Environments
+==================
+These conda environments are specified in Yaml files, and are loaded into
+the conda-based Docker image. All the dependencies are loaded from the
+`conda-forge <https://anaconda.org/conda-forge/>`_ Anaconda channel.
+
+kwant-stable-no-extras
+  The minimal environment in which Kwant can run. Pins all the dependencies to
+  the oldest supported versions, and does not include optional dependencies.
+
+kwant-stable
+  Pins all the dependencies to the oldest supported versions, including all
+  optional dependencies.
+
+kwant-latest
+  References all Kwant dependencies, but does not pin any versions, meaning
+  that the latest released versions of the dependencies are used (at least,
+  the latest released versions on conda-forge)
diff --git a/docker/kwant-latest.yml b/docker/kwant-latest.yml
new file mode 100644
index 00000000..29305536
--- /dev/null
+++ b/docker/kwant-latest.yml
@@ -0,0 +1,29 @@
+name: kwant-latest
+channels:
+    - conda-forge
+dependencies:
+    - python=3.6
+    - numpy
+    - scipy
+    - tinyarray
+    - sympy
+    - matplotlib
+    # Linear algebra libraraies
+    - mumps
+    - blas #=1.1 openblas
+    - openblas #=0.2.20
+    # Build toolchain
+    - toolchain
+    - cython
+    - gcc
+    - libgfortran
+    ## Dev Dependencies
+    # Testing
+    - pytest
+    - pytest-cov
+    - pytest-flakes
+    - pytest-pep8
+    # Documentation building
+    - sphinx=1.7.4  # later versions seem to have problems
+    - numpydoc
+    - requests
diff --git a/docker/kwant-stable-no-extras.yml b/docker/kwant-stable-no-extras.yml
new file mode 100644
index 00000000..59dd6984
--- /dev/null
+++ b/docker/kwant-stable-no-extras.yml
@@ -0,0 +1,26 @@
+name: kwant-stable-no-extras
+channels:
+    - conda-forge
+dependencies:
+    - python=3.5
+    - numpy=1.11.0
+    - scipy=0.17  # No minor version because conda-forge has no 0.17.0
+    - tinyarray=1.2.0
+    # Linear algebra libraraies
+    - blas #=1.1 openblas
+    - openblas #=0.2.20
+    # Build toolchain
+    - toolchain
+    - cython
+    - gcc
+    - libgfortran
+    ## Dev Dependencies
+    # Testing
+    - pytest
+    - pytest-cov
+    - pytest-flakes
+    - pytest-pep8
+    # Documentation building
+    - sphinx=1.7.4  # later versions seem to have problems
+    - numpydoc
+    - requests
diff --git a/docker/kwant-stable.yml b/docker/kwant-stable.yml
new file mode 100644
index 00000000..99f79260
--- /dev/null
+++ b/docker/kwant-stable.yml
@@ -0,0 +1,29 @@
+name: kwant-stable
+channels:
+    - conda-forge
+dependencies:
+    - python=3.5
+    - numpy=1.11.0
+    - scipy=0.17  # No minor version because conda-forge has no 0.17.0
+    - tinyarray=1.2.0
+    - sympy=0.7.6
+    - matplotlib=1.5.1
+    # Linear algebra libraraies
+    - mumps
+    - blas #=1.1 openblas
+    - openblas #=0.2.20
+    # Build toolchain
+    - toolchain
+    - cython
+    - gcc
+    - libgfortran
+    ## Dev Dependencies
+    # Testing
+    - pytest
+    - pytest-cov
+    - pytest-flakes
+    - pytest-pep8
+    # Documentation building
+    - sphinx=1.7.4  # later versions seem to have problems
+    - numpydoc
+    - requests
-- 
GitLab