Commit 18e9c332 authored by Dave Moxey's avatar Dave Moxey

Add automated docker builds for Nektar++, a build environment and a Jupyter notebook image.

parent ff1e5b8c
# Exclude the usual build environment stuff.
.clang-format
.git
.gitignore
.gitlab-ci.yml
ThirdParty
build
builds
.DS_Store
# Make sure Dockerfiles aren't included in build context to
# improve caching.
pkg/docker/nektar/Dockerfile
pkg/docker/nektar-workbook/Dockerfile
pkg/docker/nektar-env/Dockerfile
.*
!.gitignore
!.gitlab-ci.yml
!.gitattributes
!.clang-format
!.dockerignore
# Ignore builds and ThirdParty directories
build
builds
......
stages:
- docker-build-env
- docker-build-image
- docker-test-image
- docker-cleanup-image
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
.docker_build_template: &docker_build_template
image: docker:stable
stage: docker-build-image
only:
- master
- /^docker\/.*$/
script:
- docker pull ${image_name} || true
- DOCKER_BUILDKIT=1 docker build -t ${image_name} -f ${dockerfile} .
- docker tag ${image_name} ${image_name}:$CI_COMMIT_SHORT_SHA
- docker push ${image_name}:$CI_COMMIT_SHORT_SHA
- if [ ! -z $CI_COMMIT_TAG ]; then docker tag ${image_name} ${image_name}:$CI_COMMIT_TAG; docker push ${image_name}:$CI_COMMIT_TAG; fi
- docker push ${image_name}:latest
.docker-test-template: &docker_test_template
image: docker:stable
stage: docker-test-image
only:
- master
- /^docker\/.*$/
script:
- docker pull ${image_name} || true
- docker create --name ${container_name}-$CI_COMMIT_SHORT_SHA -t ${image_name}:latest
- docker cp $(pwd)/${test_dir} ${container_name}-$CI_COMMIT_SHORT_SHA:/docker-entrypoint
- docker start ${container_name}-$CI_COMMIT_SHORT_SHA
- docker exec ${container_name}-$CI_COMMIT_SHORT_SHA ${test_cmd}
- docker rm -f ${container_name}-$CI_COMMIT_SHORT_SHA
docker-build-env:
<<: *docker_build_template
stage: docker-build-env
variables:
image_name: nektarpp/nektar-env
dockerfile: pkg/docker/nektar-env/Dockerfile
only:
refs:
- master
- /^docker\/.*$/
changes:
- pkg/docker/nektar-env/Dockerfile
docker-build-nektar:
<<: *docker_build_template
variables:
image_name: nektarpp/nektar
dockerfile: pkg/docker/nektar/Dockerfile
docker-build-workbook:
<<: *docker_build_template
variables:
image_name: nektarpp/nektar-workbook
dockerfile: pkg/docker/nektar-workbook/Dockerfile
docker-test-nektar:
<<: *docker_test_template
variables:
image_name: nektarpp/nektar
container_name: nektar
test_dir: solvers/IncNavierStokesSolver/Tests
test_cmd: mpirun -n 3 IncNavierStokesSolver data/ChanFlow_m3_par.xml
docker-cleanup-nektar:
stage: docker-cleanup-image
when: on_failure
script:
- docker rm -f nektar-$CI_COMMIT_SHORT_SHA
......@@ -190,6 +190,9 @@ v5.0.0
**Tester**
- Fix build with boost 1.67 (!947)
**Packaging:**
- Add Dockerfiles and gitlab CI configuration for automatic builds (!1021)
v4.4.2
------
**Library**
......
FROM debian:buster-slim
LABEL maintainer="David Moxey <d.moxey@exeter.ac.uk>"
RUN DEBIAN_RELEASE=buster && \
echo "deb http://deb.debian.org/debian ${DEBIAN_RELEASE} non-free" > \
/etc/apt/sources.list.d/debian-non-free.list && \
apt-get update && \
apt-get install -y build-essential cmake git \
libboost-thread-dev libboost-iostreams-dev libboost-filesystem-dev libboost-system-dev \
libboost-program-options-dev libboost-python-dev libboost-numpy-dev libboost-regex-dev \
libfftw3-dev libhdf5-dev libhdf5-mpi-dev liblapack-dev liboce-foundation-dev \
liboce-modeling-dev liboce-ocaf-dev libtet1.5-dev libtriangle-dev \
libtinyxml-dev mpi-default-dev petsc-dev zlib1g-dev python-numpy libptscotch-dev \
libarpack2-dev
RUN groupadd nektar && useradd -m -g nektar nektar
USER nektar:nektar
WORKDIR /home/nektar
# `nektar-env` image
This image is designed to provide a build environment for Nektar++ based on the
Debian 10 (buster) build image. It installs all libraries to enable Nektar++ to
be compiled with most/all third-party dependencies turned on. In particular we
install the following development libraries:
- Boost
- TinyXML
- LAPACK/BLAS
- OpenMPI (enables `NEKTAR_USE_MPI`)
- FFTW (enables `NEKTAR_USE_FFT`)
- Python and Boost.Python (enables `NEKTAR_BUILD_PYTHON`)
- HDF5 (enables `NEKTAR_USE_HDF5`)
- OCE, Triangle and TetGen (enables `NEKTAR_USE_MESHGEN`)
- PETSc (enables `NEKTAR_USE_PETSC`)
- ARPACK (enables `NEKTAR_USE_ARPACK`)
## Building
No particular context is required to build this image. Building using the below
or similar.
```sh
docker build -t nektarpp/nektar-env -f Dockerfile .
```
FROM jupyter/scipy-notebook:ae5f7e104dd5 AS build
USER root
RUN apt-get update && \
apt-get install -y libtinyxml-dev && \
rm -rf /var/lib/apt/lists/*
USER $NB_UID
RUN conda install --quiet --yes cmake==3.14.3 boost==1.69 jupyter_contrib_nbextensions && \
jupyter contrib nbextension install --sys-prefix && \
jupyter nbextension enable --sys-prefix hide_input/main && \
jupyter nbextension enable --sys-prefix hide_input_all/main && \
jupyter nbextension enable --sys-prefix init_cell/main && \
jupyter nbextension enable --sys-prefix equation-numbering/main
USER root
COPY . /tmp/nektar
RUN cd /tmp/nektar && mkdir build && cd build && \
cmake -DNEKTAR_BUILD_SOLVERS=OFF -DNEKTAR_BUILD_UTILITIES=ON -DNEKTAR_BUILD_PYTHON=ON \
-DNEKTAR_USE_PYTHON3=ON -DNEKTAR_BUILD_TESTS=OFF -DNEKTAR_BUILD_UNIT_TESTS=OFF \
-DNEKTAR_BUILD_DEMOS=OFF -DNEKTAR_USE_SCOTCH=OFF -DCMAKE_INSTALL_PREFIX=/usr/local .. && \
make -j$(nproc) install && \
chown -R $NB_UID:$NB_UID /tmp/nektar && \
cd /tmp/nektar/build && sudo -u $NB_USER make nekpy-install-system && cd && rm -R /tmp/nektar
USER $NB_UID
\ No newline at end of file
# `nektar-workbook` image
This image is based on the `scipy-notebook` image but augments it with the
`NekPy` Python interface. It also includes the `NekMesh` and `FieldConvert`
utilities for post-processing.
## Building
The image requires as build context the path to the Nektar++ source tree. Build
the image using a command similar to:
```sh
docker build -t nektarpp/nektar-notebook -f Dockerfile ~/nektar++
```
FROM nektarpp/nektar-env:latest AS build
LABEL maintainer="David Moxey <d.moxey@exeter.ac.uk>"
COPY --chown=nektar:nektar . /home/nektar
ARG BUILD_DEMOS=OFF
ARG BUILD_SOLVERS=ON
ARG INSTALL_PREFIX=/usr/local
RUN mkdir build && cd build && \
cmake \
-DNEKTAR_BUILD_DEMOS=${BUILD_DEMOS} \
-DNEKTAR_BUILD_TESTS=OFF \
-DNEKTAR_BUILD_UNIT_TESTS=OFF \
-DNEKTAR_BUILD_SOLVERS=${BUILD_SOLVERS} \
-DNEKTAR_BUILD_PYTHON=ON \
-DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
-DNEKTAR_USE_MESHGEN=ON \
-DNEKTAR_USE_MPI=ON \
-DNEKTAR_USE_ARPACK=ON \
-DNEKTAR_USE_FFTW=ON \
-DNEKTAR_USE_HDF5=ON \
-DNEKTAR_USE_CCM=ON \
.. && \
make -j$(nproc)
USER root
RUN cd build && make install && make nekpy-install-system && cd ..
USER nektar
FROM debian:buster-slim
RUN DEBIAN_RELEASE=buster && \
echo "deb http://deb.debian.org/debian ${DEBIAN_RELEASE} non-free" > \
/etc/apt/sources.list.d/debian-non-free.list && \
apt-get update && \
apt-get install -y \
openssh-client nano vim binutils \
libboost-thread1.67 libboost-iostreams1.67 libboost-filesystem1.67 libboost-system1.67 \
libboost-program-options1.67 libboost-python1.67 libboost-regex1.67 libboost-numpy1.67 \
libfftw3-3 libhdf5-103 libhdf5-openmpi-103 liblapack3 liboce-foundation11 \
liboce-modeling11 liboce-ocaf11 libtet1.5 libtriangle-1.6 python-numpy \
openmpi-bin libpetsc3.10 libptscotch-6.0 libarpack2 libtinyxml2.6.2v5 && \
apt-get clean && rm -rf /var/lib/apt/lists/*
ARG INSTALL_PREFIX=/usr/local
COPY --from=build ${INSTALL_PREFIX} ${INSTALL_PREFIX}
# Set up entrypoint for copying test files.
COPY pkg/docker/nektar/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh && \
ln -s /usr/local/bin/docker-entrypoint.sh /
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
RUN groupadd nektar && useradd -m -g nektar nektar
USER nektar
WORKDIR /home/nektar
CMD ["/bin/bash"]
# `nektar` image
This image provides a full installation of Nektar++ with the following options
enabled:
- `NEKTAR_USE_MPI`
- `NEKTAR_USE_FFT`
- `NEKTAR_BUILD_PYTHON`
- `NEKTAR_USE_HDF5`
- `NEKTAR_USE_MESHGEN`
- `NEKTAR_USE_PETSC`
- `NEKTAR_USE_CCM`
## Building
The image is built using `nektarpp/nektar-env` and requires as build context the
path to the Nektar++ source tree. It supports three additional build arguments:
- `BUILD_DEMOS` can be set to `ON` to build demos, which are disabled by
default;
- `BUILD_SOLVERS` can be set to `OFF` to disable build of solvers, which are
enabled by default;
- `INSTALL_PREFIX` can be set to adjust the install prefix, which is
`/usr/local` by default.
Then build the image using a command similar to:
```sh
docker build -t nektarpp/nektar -f Dockerfile ~/nektar++
```
Note that this is a multi-stage build: after the initial build phase is
completed, the build tree is erased along with development headers, and the
libraries/executables installed into a fresh Debian 10 container (with
appropriate packages for runtime libraries). If you want to keep the build
files, you should instead only build up to the end of the build stage using
`--target build`:
```sh
docker build --target build -t nektar-build -f Dockerfile ~/nektar++
```
#!/bin/bash
set -e
if [ -d /docker-entrypoint ]; then
mkdir -p $HOME/data
cp -r /docker-entrypoint/* $HOME/data
fi
exec "$@"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment