This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Convert config files into docker commands

Project Description
# Wharf-Rat

![Build Status](http://paulbecotte.com:8082/buildStatus/icon?job=Wharfrat)
CI is at [paulbecotte.com](http://paulbecotte.com:8082)

A simple tool to translate yml config files into docker commands.

## Install

`pip install wharfrat`

## Basics

Wharfrat is designed to help automate development workflows involving
docker containers. The idea is extended upon docker-compose, where you
lay out the details of your containers in a yaml file. With wharfrat, you
specify your containers details in a docker-compose.yml file, and then add
on wharfrat.yml. wharfrat.yml specifies the tasks that you want to run
using them. The idea is to support workflows like deploying a tagged
version of containers, running a command in a set of linked containers and
then committing the result to an image, or waiting for one container to
launch before launching the next one.

A task is a set of docker containers that are run together. The only
implemented scheme is a basic task command. This stands up a list of
dependent instances daemonized, and then launches one instance in the
foreground. When this instance exits it and all of the dependant containers
are cleaned up (docker rm -fv).

## Tasks

```
test:
type: task
compose_file: sample-docker-compose.yml
primary: webapp
images:
- redis
- mysql
- postgres
- celeryd
```

This creates a task with the name "test". The containers in primary and images
must be specified by name elsewhere in the file. Images are started with
`docker run -d ...`. The primary is run with `docker run --rm`.

## Instances

Instances are read from the yml file specified in the task definition.
Only the images listed in the task definition are run.

```
webapp:
type: instance
image: busybox
links:
- redis:redis
- mysql:mysql
environment:
- ENV=local
- PYTHONPATH=/data
volumes:
- .:/data
workdir: /data
entrypoint: python
command: setup.py test
```


This is an instance named "webapp". It uses the image "busybox". You can also
give it a command `build: mydir` which will cause it to run `docker build mydir`
and use the resultant image. If you specify a build command, you can also
specify a dockerfile command, witht the same argument as the -f argument to
docker build. If paths in the file are relative, they will be resolved relative
to the yml file, not the working directory (similar to Make)

## Running a task

`wharfrat -f <CONFIG_FILE.yml> run <MY_TASK>`

If you don't specify a config file, it will look for "wharfrat.yml" in the
current working directory. <MY_TASK> is the name of the task to run.

## Templates

You can use string format blocks in your values for container instances, and
specify defaults in your task definitions. For example-

```yaml
test-task:
type: task
primary: hello-world
context:
- arg=hello
hello-world:
type: instance
image: busybox
command: "echo {arg} world"
```

Running this `wharfrat run test-task` will run `docker run busybox echo hello world`
It is important to use quotes around your strings if you are putting variables
in your yaml file- otherwise yaml may interpret your argument as a dict or
scalar which won't compile as you like. You can override template args on the
command line. `wharfrat run test-task arg=goodbye` will run `docker run busybox
goodbye world`.


# Develop

```
virtualenv -p python2.7 venv
source venv/bin/activate
python setup.py develop
python setup.py test
```

Alternatively, use Wharfrat to run the tests (requires local docker)...

```
virtualenv -p python2.7 venv
source venv/bin/activate
python setup.py develop
wharfrat run build
```

## Run docker on OSX

```
brew install docker
brew install boot2docker
boot2docker init
boot2docker up
```

(copy the three `export` commands that `boot2docker` outputs into your `~/.profile` or similar file)
Release History

Release History

This version
History Node

0.2.0

History Node

0.1.1

History Node

0.1

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
wharfrat-0.2.0-py2-none-any.whl (9.7 kB) Copy SHA256 Checksum SHA256 py2 Wheel Jul 1, 2015
wharfrat-0.2.0.tar.gz (5.7 kB) Copy SHA256 Checksum SHA256 Source Jul 1, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting