Skip to content

Instantly share code, notes, and snippets.

@wd15
Last active March 7, 2016 02:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wd15/d233c706bb493c91ecd5 to your computer and use it in GitHub Desktop.
Save wd15/d233c706bb493c91ecd5 to your computer and use it in GitHub Desktop.
Docker build for PyMKS

Try PyMKS using Docker

Install Docker

Install Docker and run the Deamon. See https://docs.docker.com/engine/installation/linux/ubuntulinux/ for installation details.

$ sudo service docker start

Pull the Docker instance

Pull the Docker Instance from Dockerhub

$ docker pull docker.io/wd15/pymks

Test PyMKS

Test the build inside the instance.

$ docker run -i -p 8888:8888 --net=host -t wd15/pymks:latest

and go to http://localhost:8888 and run import pymks; pymks.test in a notebook.

Build the Docker instance

Clone this repository and build the instance.

$ git clone https://gist.github.com/d233c706bb493c91ecd5.git pymks-dockerize
$ cd pymks-dockerize
$ docker build --no-cache -t wd15/pymks:latest .

Push the Docker instance

Create the repository in Dockerhub and then push it.

$ docker login
$ docker push docker.io/wd15/pymks:latest
---
- 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"
---
python_version: 2
## Docker file to create an install using a bash script and run a
## service.
FROM ubuntu:15.10
MAINTAINER wd15 "https://github.com/wd15"
## 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
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 -- this should be a service set up as part of
## playbook
WORKDIR /home/testuser/pymks/notebooks
CMD ~/anaconda/bin/ipython 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 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 $@
---
- name: playbook to install anaconda
hosts: local
connection: local
vars:
local_path: "{{ lookup('env', 'HOME') }}"
anaconda_path: "{{ local_path }}/anaconda"
pymks_path: "{{ local_path }}/pymks"
sfepy_path: "{{ local_path }}/sfepy"
vars_files:
- config.yml
tasks:
- include: anaconda.yml
- include: pymks.yml
---
- name: apt-get installs
apt:
name: "{{ item }}"
state: present
force: yes
with_items:
- git
- gcc
become: true
- name: clone sfepy
git:
repo: https://github.com/sfepy/sfepy.git
dest: "{{ sfepy_path}}"
version: master
- name: install sfepy
command: "{{ anaconda_path}}/bin/python setup.py install"
args:
chdir: "{{ sfepy_path }}"
- name: clone pymks
git:
repo: https://github.com/materialsinnovation/pymks.git
dest: "{{ pymks_path }}"
version: develop
- name: install pymks
command: "{{ anaconda_path}}/bin/python setup.py install"
args:
chdir: "{{ pymks_path }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment