Skip to content

Instantly share code, notes, and snippets.

@tkphd
Last active May 13, 2016 21:31
Show Gist options
  • Save tkphd/299bdc8eda1879551b9d7499821fcd79 to your computer and use it in GitHub Desktop.
Save tkphd/299bdc8eda1879551b9d7499821fcd79 to your computer and use it in GitHub Desktop.
Docker build for MMSP spinodal decomposition

Try MMSP using Docker

This Docker container downloads MMSP, builds its utility programs, and updates relevant environmental variables to enable serial and parallel builds of MMSP code. The Docker image is designed to run a Jupyter notebook showcasing the workflow for a spinodal decomposition problem, originally written for the First CHiMaD Phase Field Hackathon.

Install and familiarize yourself with Docker

Follow the excellent instructions on the Docker webpage. It's worth working through the cowsay example.

Pull the instance from Dockerhub

$ docker pull tkphd/chimad-mmsp:latest

Run the container

$ docker run -i -p 8888:8888 --net=host -t tkphd/chimad-mmsp:latest

Use the notebook

Open a browser to http://localhost:8888, then click the link to CahnHilliard2DNeumann.ipynb. Note that running the full notebook, especially in serial or with few cores, could take a week. Read through what's already there before clearing the output!

To build the Docker or tinker with the mechanism, clone the gist

git clone https://gist.github.com/tkphd/299bdc8eda1879551b9d7499821fcd79

Acknowledgment

This Docker build was created using wd15's pymks Docker build as a guide.

---
- name: apt-get installs
apt:
name: "{{ item }}"
state: present
force: yes
with_items:
- bzip2
- libglib2.0-0
become: true
- name: check if anaconda is installed
stat: path={{ anaconda_path }}
register: anaconda_dir
- name: download miniconda
get_url:
url: https://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh
dest: /tmp
force: no
validate_certs: no
when: anaconda_dir.stat.exists == False
- name: install miniconda
shell: bash /tmp/Miniconda-latest-Linux-x86_64.sh -b -p {{ anaconda_path }}
args:
creates: "{{ anaconda_path }}"
when: anaconda_dir.stat.exists == False
- name: update conda
shell: "{{ anaconda_path }}/bin/conda update conda"
- name: install anaconda
shell: "{{ anaconda_path }}/bin/conda install anaconda"
- name: install matplotlib
shell: "{{ anaconda_path }}/bin/conda install matplotlib"
- name: install numpy
shell: "{{ anaconda_path }}/bin/conda install numpy"
---
python_version: 2
# Docker file to install MMSP in a Ubuntu container
# with a Jupyter notebook exposed on port 8888
#
# Cloned from https://gist.github.com/wd15/d233c706bb493c91ecd5
#
FROM ubuntu:15.10
MAINTAINER Trevor Keller "https://github.com/tkphd"
## Install only required packages for making a user as the
## `setup.bash` script installs most of the required packages
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get -y update
RUN apt-get install -y apt-utils
RUN apt-get install -y sudo
## Create a user with no sudo password.
RUN useradd -m testuser
RUN passwd -d testuser
RUN adduser testuser sudo
RUN echo 'testuser ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
## Copy the ansible scripts into the container
USER testuser
WORKDIR /home/testuser
ENV MMSP_PATH /home/testuser/mmsp
ENV PATH $MMSP_PATH/utility:$PATH
COPY *.yml docker/
COPY *.bash docker/
COPY HOSTS docker/
RUN sudo chown testuser:testuser docker -R
WORKDIR /home/testuser/docker
## Install everything using the Ansible playbook
RUN ./install.bash
## Run the server -- should be a service set up as part of playbook
WORKDIR /home/testuser/mmsp/notebooks
CMD ~/anaconda/bin/jupyter notebook --no-browser
EXPOSE 8888
[local]
127.0.0.1
#!/bin/bash
#if ! dpkg -s ansible > /dev/null; then
sudo apt-get install -y ansible g++ libmpich2-dev libpng12-dev make mpich2 python-apt
#fi
## be sure to use the system python with ansible at this point
export PATH=/usr/bin:$PATH
ansible-playbook install.yml -i HOSTS $@
wget --directory-prefix=/home/testuser/mmsp/ https://raw.githubusercontent.com/tkphd/CHiMaD-Hackathon/master/Hackathon1/Cahn-Hilliard/energy.hpp
wget --directory-prefix=/home/testuser/mmsp/notebooks/ https://raw.githubusercontent.com/tkphd/CHiMaD-Hackathon/master/Hackathon1/Cahn-Hilliard/1b_Neumann/Makefile
wget --directory-prefix=/home/testuser/mmsp/notebooks/ https://raw.githubusercontent.com/tkphd/CHiMaD-Hackathon/master/Hackathon1/Cahn-Hilliard/1b_Neumann/cahn-hilliard.hpp
wget --directory-prefix=/home/testuser/mmsp/notebooks/ https://raw.githubusercontent.com/tkphd/CHiMaD-Hackathon/master/Hackathon1/Cahn-Hilliard/1b_Neumann/cahn-hilliard.cpp
wget --directory-prefix=/home/testuser/mmsp/notebooks/ https://raw.githubusercontent.com/tkphd/CHiMaD-Hackathon/master/Hackathon1/Cahn-Hilliard/1b_Neumann/CahnHilliard2DNeumann.ipynb
---
- name: playbook to install mmsp
hosts: local
connection: local
vars:
local_path: "{{ lookup('env', 'HOME') }}"
anaconda_path: "{{ local_path }}/anaconda"
mmsp_path: "{{ local_path }}/mmsp"
vars_files:
- config.yml
tasks:
- include: anaconda.yml
- include: mmsp.yml
---
- name: apt-get installs
apt:
name: "{{item}}"
state: present
force: yes
with_items:
- git
- gcc
become: true
- name: clone mmsp
git:
repo: https://github.com/mesoscale/mmsp.git
dest: "{{mmsp_path}}"
version: master
- name: install mmsp
command: "make"
args:
chdir: "{{mmsp_path}}/utility"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment