Skip to content

Automated Deployment (Docker)

James Case edited this page Feb 19, 2015 · 24 revisions

OOI UI Docker Images and Containers

The following describes the process by which the OOI UI and associated OOI UI Services and database server are built and launched in order to obtain a complete distribution of the OOI UI.

TODO:

  • Add support for launching the OOI UI stack for a specific release

Host Configuration

These instructions are meant to be used on a CentOS 6.x server as the root user.

Install required system packages

yum -y update
yum -y install epel-release
yum -y groupinstall 'Development Tools'
yum -y install git
yum -y install wget
yum -y install bzip2
yum -y install bzip2-devel
yum -y install tar
yum -y update gmp
yum -y install db4-devel
yum -y install db4-devel-static
yum -y install zlib
yum -y install zlib-devel
yum -y install gcc
yum -y install openssl-devel
yum -y install libxml2-devel
yum -y install libxslt-devel
yum -y install libcurl-devel
yum -y install sqlite-devel
yum -y install readline-devel
yum -y install db4-devel
yum -y install db4-devel-static
yum -y install ctags-etags
yum -y install tmux
yum -y install java-1.7.0-openjdk-devel
yum -y install docker-io
chkconfig docker on
service docker start

cd /tmp
wget http://python.org/ftp/python/2.7.6/Python-2.7.6.tgz && tar -xzvf Python-2.7.6.tgz -C /usr/local/src/
rm -rf Python-2.7.6.tgz
cd /usr/local/src/Python-2.7.6
./configure --with-zlib --prefix=/usr/local && /usr/bin/make && /usr/bin/make altinstall
ln -s /usr/local/bin/python2.7 /usr/local/bin/python27

cd /root
wget https://raw.githubusercontent.com/brainsik/virtualenv-burrito/master/virtualenv-burrito.sh
chmod +x virtualenv-burrito.sh
./virtualenv-burrito.sh
chmod +x /root/.venvburrito/startup.sh
source /root/.venvburrito/startup.sh && mkvirtualenv --no-site-packages --python=/usr/local/bin/python27 ooiui

Quick Start

This quick-start is the recommended procedure for deploying the OOI UI stack

Host Setup

  • Make sure you have a Python 2.7.x virtual environment installed and running

  • Install docker-compose requirements:

    wget https://raw.githubusercontent.com/docker/fig/master/requirements.txt

    pip install -r requirements.txt

  • Install docker-compose:

    pip install docker-compose==1.1.0-rc2

Run docker-compose to fetch and launch the entire OOI UI stack

wget https://raw.githubusercontent.com/oceanzus/ooi-ui-deployments/master/docker-compose.yml
  • Edit docker-compose.yml as necessary for the installation environment

Run the OOI UI stack by executing:

docker-compose up

Stop the OOI UI stack

docker-compose stop

Reload the OOI UI stack (update all software)

docker-compose pull

The OLD Way

Step 1: Launch PostgreSQL Service

Build Image or Fetch from DockerHub

git clone https://github.com/oceanzus/docker-postgis.git

sudo docker build --no-cache=true -t="oceanzus/docker_postgis:v1" .

Launch Container

mkdir $HOME/postgres_data

from command line:

sudo docker run -e USERNAME=<username> -e PASS=<password> -d --name ooiuidb -v $HOME/postgres_data:/var/lib/postgresql oceanzus/docker_postgis:v1

using supervisord:

sudo docker run -e USERNAME=<username> -e PASS=<password> -a stdout -a stderr --rm=true --name ooiuidb -v $HOME/postgres_data:/var/lib/postgresql oceanzus/docker_postgis:v1

Optional - Connect to Container (psql)

sudo docker ps

sudo docker inspect <container id>

psql -h <ip from inspect> -U <username> -W postgres

Step 2: Run OOI UI Services

Build Image

git clone https://github.com/oceanzus/ooi-ui-services-deploy.git

sudo docker build --no-cache=true -t="oceanzus/ooi_ui_services_deploy:v1" .

Launch Container

from command line:

sudo docker run -e HOST_IP=0.0.0.0 -e DB_PORT=<port> -e DB_USER=<user> -e DB_PASS=<password> -e DB_HOST=<url> -e DB_NAME=<database name> -e DB_RESET=<true|false> -d --name ooiuiservices --link ooiuidb:ooiuidb oceanzus/ooi_ui_services_deploy:v1

using supervisord:

sudo docker run -e HOST_IP=0.0.0.0 -e DB_PORT=<port> -e DB_USER=<user> -e DB_PASS=<password> -e DB_HOST=<url> -e DB_NAME=<database name> -e DB_RESET=<true|false> -a stdout -a stderr --rm=true --name ooiuiservices --link ooiuidb:ooiuidb oceanzus/ooi_ui_services_deploy:v1

Optional - Manual Container Startup

sudo docker run -e HOST_IP=0.0.0.0 -e DB_PORT=<port> -e DB_USER=<user> -e DB_PASS=<password> -e DB_HOST=<url> -e DB_NAME=<database name> -e DB_RESET=<true|false> -t -i --name ooiuiservices --link ooiuidb:ooiuidb oceanzus/ooi_ui_services_deploy:v1 /bin/bash

./start_ooi-ui-services.sh

Step 3: Run OOI UI

Build Image

git clone https://github.com/oceanzus/ooi-ui-deploy.git

sudo docker build --no-cache=true -t="oceanzus/ooi_ui_deploy:v1" .

Launch Container

from command line:

sudo docker run -d -p <host external ip>:5000:5000 --name ooiui --link ooiuiservices:ooiuiservices oceanzus/ooi_ui_deploy:v1

from supervisord:

sudo docker run -a stdout -a stderr --rm=true -p <host external ip>:5000:5000 --name ooiui --link ooiuiservices:ooiuiservices oceanzus/ooi_ui_deploy:v1

Optional - Manual Container Startup

sudo docker run -t -i -p <host external ip>:5000:5000 --name ooiui --link ooiuiservices:ooiuiservices oceanzus/ooi_ui_deploy:v1 /bin/bash

./start_ooi-ui.sh


Stop ALL Docker Containers

sudo docker stop $(sudo docker ps -a -q)

Remove ALL Docker containers

sudo docker rm $(sudo docker ps -a -q)

Remove ALL Docker images

sudo docker rmi $(sudo docker images -q)


Deployment Example using Docker Hub Images on New CentOS 6.x Server/VM

  • Create CentOS 6.x Server or VM
  • Log in as root
  • Make sure root volume is proper size if larger than default (EC2-related)

sudo resize2fs /dev/xvde

  • Install Docker and set-up ooiui user

yum -y install epel-release

yum -y install docker-io

chkconfig docker on

service docker start

adduser ooiui

vi /etc/sudoers

Add the following: ooiui ALL=(ALL) NOPASSWD: ALL

su - ooiui

  • Run the Docker management app DockerUI (optional)

sudo docker run -d -p 9000:9000 --privileged -v /var/run/docker.sock:/var/run/docker.sock dockerui/dockerui

mkdir $HOME/postgres_data

  • Start the PostgreSQL container

sudo docker run -e USERNAME=ooiui -e PASS=ooiui -d --name ooiuidb -v $HOME/postgres_data:/var/lib/postgresql oceanzus/docker_postgis

  • Start the ooi-ui-services container (remember to use your own IP address in the -p option)

sudo docker run -e HOST_IP=0.0.0.0 -e DB_PORT=5432 -e DB_USER=ooiui -e DB_PASS=ooiui -e DB_HOST=ooiuidb -e DB_NAME=ooiuidev -e DB_RESET=true -p 10.181.61.91:4000:4000 -d --name ooiuiservices --link ooiuidb:ooiuidb oceanzus/ooi-ui-services-deploy

  • Start the first ooi-ui container

sudo docker run -d --name ooiui1 --link ooiuiservices:ooiuiservices oceanzus/ooi-ui-deploy

  • Start the second ooi-ui container

sudo docker run -d --name ooiui2 --link ooiuiservices:ooiuiservices oceanzus/ooi-ui-deploy

  • Start the HAProxy load balancer bound to the EC2 internal (eth0) IP address on port 80

sudo docker run -d --link ooiui1:ooiui1 --link ooiui2:ooiui2 --name ooiui-haproxy -e PORT=5000 -p 10.181.61.91:80:80 oceanzus/haproxy

How to do a full deployment update

  • Stop all Docker containers sudo docker stop $(sudo docker ps -a -q)

  • Remove all Docker containers sudo docker rm $(sudo docker ps -a -q)

  • Pull the latest images from Docker Hub sudo docker pull oceanzus/docker_postgis

sudo docker pull oceanzus/ooi-ui-services-deploy

sudo docker pull oceanzus/ooi-ui-deploy

sudo docker pull oceanzus/haproxy

Note that the postgresql container (ooiuidb in this example) will use the existing database files in $HOME/postgres_data and DB_RESET=true could be changed to DB_RESET=false if ooi-ui-services-deploy was not updated.

  • Start all Docker containers as we did above