Commit 0365b2e6 authored by Timo Koch's avatar Timo Koch
Browse files

Add Dockerfile and runscript for release 2.12

parent e141b7b1
Pipeline #1047 failed with stages
......@@ -17,6 +17,16 @@ Run
docker run -it --rm --env DISPLAY=unix$DISPLAY --device /dev/dri --volume /tmp/.X11-unix:/tmp/.X11-unix:rw dumux:latest /bin/bash
```
Running a DuMux Docker container with the script
-------------------------------------------------
In the folder dumux/release-2.12 you are going to find a script called `dumux` that spins up the container when you run
Run
```bash
./dumux open
```
Running with docker-compose
-------------------------------
......
# DuMuX docker container (version release 2.12)
# see https://github.com/phusion/baseimage-docker for information on the base image
# It is Ubuntu LTS customized for better Docker compatibility
FROM phusion/baseimage:0.9.22
MAINTAINER Timo Koch <timo.koch@iws.uni-stuttgart.de>
# run Ubuntu update as advised on https://github.com/phusion/baseimage-docker
RUN apt-get update \
&& apt-get upgrade -y -o Dpkg::Options::="--force-confold" \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# install the basic dependencies
RUN apt-get update \
&& apt-get install --no-install-recommends --yes \
ca-certificates \
vim \
python-dev \
python-pip \
git \
pkg-config \
build-essential \
gfortran \
cmake \
mpi-default-bin \
mpi-default-dev \
libsuitesparse-dev \
libsuperlu-dev \
libeigen3-dev \
doxygen \
paraview \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# add the permission helper script to the my_init service
COPY setpermissions.sh /etc/my_init.d/setpermissions.sh
# create a dumux user
# add the welcome message (copied further down) output to bashrc
# make the set permission helper script executable
# add user to video group which enables graphics if desired
RUN useradd -m --home-dir /dumux dumux \
&& echo "cat /dumux/WELCOME" >> /dumux/.bashrc \
&& chmod +x /etc/my_init.d/setpermissions.sh \
&& usermod -a -G video dumux
# Turn off verbose syslog messages as described here:
# https://github.com/phusion/baseimage-docker/issues/186
RUN touch /etc/service/syslog-forwarder/down
# switch to the dumux user and set the working directory
USER dumux
WORKDIR /dumux
# create a shared volume communicating with the host
RUN mkdir /dumux/shared
VOLUME /dumux/shared
# This is the message printed on entry
COPY WELCOME /dumux/WELCOME
# clone dune dependencies
RUN git clone -b releases/2.5 https://gitlab.dune-project.org/core/dune-common.git && \
git clone -b releases/2.5 https://gitlab.dune-project.org/core/dune-geometry.git && \
git clone -b releases/2.5 https://gitlab.dune-project.org/core/dune-grid.git && \
git clone -b releases/2.5 https://gitlab.dune-project.org/core/dune-istl.git && \
git clone -b releases/2.5 https://gitlab.dune-project.org/core/dune-localfunctions.git && \
git clone -b releases/2.5 https://gitlab.dune-project.org/staging/dune-uggrid.git && \
git clone -b releases/2.5 https://gitlab.dune-project.org/extensions/dune-alugrid.git && \
git clone -b releases/2.5 https://gitlab.dune-project.org/extensions/dune-foamgrid.git
# clone dumux repository
RUN git clone -b releases/2.12 https://git.iws.uni-stuttgart.de/dumux-repositories/dumux.git
# configure module
RUN /dumux/dune-common/bin/dunecontrol --opts=/dumux/dumux/optim.opts all
# build doxygen documentation
RUN cd dumux/build-cmake && make doc
# switch back to root
USER root
# make graphical output with paraview work
ENV QT_X11_NO_MITSHM 1
# set entry point like advised https://github.com/phusion/baseimage-docker
# this sets the permissions right, see above
ENTRYPOINT ["/sbin/my_init","--quiet","--","/sbin/setuser","dumux","/bin/bash","-l","-c"]
# start interactive shell
CMD ["/bin/bash","-i"]
Welcome to the dumux Docker container (version 2.12). You compile and run test / examples
in the folder build-cmake/test.
Copying the output like VTK files to the folder /dumux/shared will make them available
outside this container on the host for display.
This docker container also has graphics support on Linux systems.
#!/usr/bin/env bash
# the image name
PUB_IMAGE_NAME=dumux/release-2.12
# the host directory that is mounted into...
SHARED_DIR_HOST="$(pwd)"
# ...this container directory.
SHARED_DIR_CONTAINER="/dumux/shared"
executeandlog ()
{
echo "[$@]"
eval $@
}
help ()
{
echo ""
echo "Usage: dumux <command> [options]"
echo ""
echo " dumux open [image] - open a DuMuX Docker container."
echo " dumux help - display this message."
echo ""
echo "Optionally supply an Docker image name to the open command."
echo ""
}
# open the dumux container. Only argument is the Docker image.
open()
{
IMAGE="$1"
COMMAND="docker create -i -t \
-e HOST_UID=$(id -u $USER) \
-e HOST_GID=$(id -g $USER) \
-e DISPLAY=unix$DISPLAY \
--device /dev/dri \
-v $SHARED_DIR_HOST:$SHARED_DIR_CONTAINER \
-v /tmp/.X11-unix:/tmp/.X11-unix:rw \
--name dumux \
$IMAGE /bin/bash"
CONTAINER_NAME=$(executeandlog $COMMAND | tail -n 1)
executeandlog docker start -a -i $CONTAINER_NAME
executeandlog docker rm $CONTAINER_NAME
}
# Check if user specified valid command otherwise print help message
if [ "$1" == "open" ]; then
IMAGE="$2" : ${IMAGE:="$PUB_IMAGE_NAME"}
open $IMAGE
else
help
exit 1
fi
#!/bin/bash
# The user can pass the user and group id by passing
# --env HOST_UID=$(id -u $USER) --env HOST_GID=$(id -g $USER)
# with the UID on the host to the container. Should work for Linux, Mac and Windows.
# Allows to manage the writes for shared volumes.
if [ "$HOST_UID" ]; then
usermod -u $HOST_UID dumux
fi
if [ "$HOST_GID" ]; then
groupmod -g $HOST_GID dumux
fi
# Make sure that everything in /dumux is accessible by the dumux user
# sed "1d" removes first line which is the folder itself
# exclude the shared folder using grep. This folder should be accessible by setting the UID/GID.
# chown transfers ownership to group dumux user dumux
# the OR true trick avoids the script exiting due to use of set -e
find /dumux -maxdepth 1 | sed "1d" | grep -v "/dumux/shared" | xargs chown -R dumux:dumux 2> /dev/null || true
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