Dockerizing stashboard - Docker meetup at Twilio

9
wilio San Francisco, CA 2013-11-13 Dockerizing Stashboard Daniel Mizyrycki [email protected]

description

Docker is an open-source project to easily create lightweight, portable, self-sufficient containers from any application. The same container that a developer builds and tests on a laptop can run at scale, in production, on VMs, bare metal, OpenStack clusters, public clouds and more.

Transcript of Dockerizing stashboard - Docker meetup at Twilio

Page 1: Dockerizing stashboard - Docker meetup at Twilio

Twilio San Francisco, CA 2013-11-13

Dockerizing Stashboard

Daniel [email protected]

Page 2: Dockerizing stashboard - Docker meetup at Twilio

What is Stashboard?

Stashboard is Twilio's open-source status dashboard for APIsand software services, powered by Google AppEngine

What is Docker?

Docker is an open-source project to easily create lightweight,portable, self-sufficient containers from any application.

Page 3: Dockerizing stashboard - Docker meetup at Twilio

Dockerizing Stashboard application

Page 4: Dockerizing stashboard - Docker meetup at Twilio

Downloads

* Download Dockerwget -O docker http://get.docker.io/builds/Linux/x86_64/docker-latest

* Download data and docker-status Stashboard Dockerfiles

wget http://raw.github.com/dotcloud/docker/master/ contrib/desktop-integration/data/Dockerfile

wget http://raw.github.com/dotcloud/docker/master/ hack/infrastructure/docker-status/Dockerfile

Page 5: Dockerizing stashboard - Docker meetup at Twilio

Data Dockerfile

# Smallest base image, just to launch a containerfrom busyboxmaintainer Daniel Mizyrycki <[email protected]>

# Create a regular userrun echo 'sysadmin:x:1000:1000::/data:/bin/sh' >> /etc/passwdrun echo 'sysadmin:x:1000:' >> /etc/group

# Create directory for that userrun mkdir /datarun chown sysadmin.sysadmin /data

# Add content to /data. This will keep sysadmin ownershiprun touch /data/init_volume

# Create /data volumeVOLUME /data

Page 6: Dockerizing stashboard - Docker meetup at Twilio

Stashboard Dockerfile

# Base docker imageFROM ubuntu:12.04MAINTAINER Daniel Mizyrycki <[email protected]>

RUN echo 'deb http://archive.ubuntu.com/ubuntu precise main universe' > \ /etc/apt/sources.listRUN apt-get updateRUN apt-get install -y less wget bzip2 unzip python-pip ca-certificates

# Install stashboard and its dependenciesRUN mkdir /application; cd /application; \ wget -q http://googleappengine.googlecode.com/files/google_appengine_1.8.7.zip; \ unzip -q /application/google_appengine_1.8.7.zip; rm google_appengine_1.8.7.zipRUN cd /application; wget -q -O - http://github.com/twilio/stashboard/tarball/master | \ tar -zx --transform 's/[^\/]*/stashboard/'

# create sysadmin accountRUN useradd -m -d /data sysadmin

# Define default server commandCMD ["/bin/sh", "-c", "/application/google_appengine/dev_appserver.py --skip_sdk_update_check \ --host 0.0.0.0 --port 8080 --admin_host 0.0.0.0 --datastore_path=/data/docker-status.db \ /application/stashboard/stashboard/app.yaml"]

Page 7: Dockerizing stashboard - Docker meetup at Twilio

Launch Docker

sudo docker -d &

Building containers

cd data; docker build -t data -rm .cd stashboard; docker build -t stashboard -rm .

Page 8: Dockerizing stashboard - Docker meetup at Twilio

Create dockerized data container

docker run -name stashboard-data data true

Running stateful firefox with dockerized data container

docker run -u 1000 -volumes-from stashboard-data \ -p 8080:8080 -p 8000:8000 stashboard

Submitting status from a service

curl -d message="Registry tests succeeded" -d status=up \ http://localhost:8080/admin/api/v1/services/registry/events

Page 9: Dockerizing stashboard - Docker meetup at Twilio