The last time Hackerfall tried to access this page, it returned a not found error. A cached version of the page is below, or clickhereto continue anyway

GitHub - nitrous-io/tug: Docker development workflow

tug

Use Docker for development

Prerequisites

Installation

Pre-built binaries

https://gobuild.io/github.com/nitrous-io/tug

Build from source

$ go get github.com/nitrous-io/tug

Set up your application

Create a Tugfile

web:      bin/web -p $PORT
postgres: docker/postgres:9.3.5
redis:    docker/redis:2.8.9

Any command that starts with docker/ will be interpreted as a docker image tag.

Create a bootstrap script

If your app needs to do any setup before it starts, create a bin/bootstrap file:

#!/bin/sh
bundle exec rake db:migrate

Make sure your bin/bootstrap is executable, i.e. chmod +x bin/bootstrap

Start the app

$ tug start
postgres | fixing permissions on existing onesory /var/lib/postgresql/data ... ok
postgres | creating subdirectories ... ok
postgres | selecting default max_connections ... 100
postgres | selecting default shared_buffers ... 128MB
web      | listening on 0.0.0.0:5000

Container linking

Tug will set environment variables in the Docker container linking format, like this:

POSTGRES_PORT_5432_TCP=tcp://127.0.0.1:5000
POSTGRES_PORT_5432_TCP_PROTO=tcp
POSTGRES_PORT_5432_TCP_ADDR=127.0.0.1
POSTGRES_PORT_5432_TCP_PORT=5000
Aliasing ENV vars

If your application expects env vars to be named differently, alias them in your Tugfile:

web: env DATABASE_HOST=$POSTGRES_PORT_5432_ADDR bundle exec rails server -p $PORT

or create a wrapper script for your process:

$ cat bin/web
#!/bin/sh
export DATABASE_URL=postgres://$POSTGRES_PORT_5432_ADDR:$POSTGRES_PORT_5432_PORT
rails server -p $PORT

Dockerfile

If your app has a Dockerfile, tug will use it to build and run your app in Docker while setting up appropriate port forwarding and file synchronization.

For Tug to work most effectively your Dockerfile should include the following:

Example Dockerfile
FROM ruby:2.1.2

ENV PORT 3000
EXPOSE 3000

WORKDIR /app
ADD . /app

Building images

Use the tug build command to build docker images from your Dockerfile and Tugfile:

$ tug build
tug: creating golang-simple.web
Sending build context to Docker daemon 2.172 MB
Sending build context to Docker daemon
Step 0 : FROM golang:1.3
 ---> b235f28e14c9
Successfully built bd03b2e73374
tug: creating golang-simple.postgres

Use tug push to push images to a docker registry:

$ tug push tutum.co/ddollar/golang-simple
tug: pushing tutum.co/ddollar/golang-simple.web
tug: pushing tutum.co/ddollar/golang-simple.postgres

Contributors

Tug is sponsored by Nitrous.IO and built by these contributors.

Continue reading on github.com