https://github.com/zk/tug
Docker development workflow
https://github.com/zk/tug
Last synced: 9 months ago
JSON representation
Docker development workflow
- Host: GitHub
- URL: https://github.com/zk/tug
- Owner: zk
- License: mit
- Created: 2014-10-23T18:54:49.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2014-10-23T20:25:00.000Z (about 11 years ago)
- Last Synced: 2025-04-01T17:28:20.823Z (9 months ago)
- Homepage:
- Size: 383 KB
- Stars: 0
- Watchers: 1
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tug
Use Docker for development
## Prerequisites
* [Docker][docker] >= 1.3
* [Golang][golang] >= 1.3
* Working `DOCKER_HOST` (non-Linux users see [boot2docker](http://boot2docker.io/))
## Installation
$ go get github.com/nitrous-io/tug
## Create a Tugfile
web: bin/web -p $PORT
postgres: docker/postgres:9.3.5
redis: docker/redis:2.8.9
If any command starts with `docker/` the rest will be interpreted as a docker image tag.
## 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](https://docs.docker.com/userguide/dockerlinks/#environment-variables), 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 bin/web
## Dockerfile
If your app has a `Dockerfile`, tug will use it to build and run your app in [Docker][docker] while setting up appropriate port forwarding and file synchronization.
For Tug to work most effectively your `Dockerfile` should include the following:
* The listening web port should be specified with an `EXPOSE` statement
* The app's code should be included from the local directory using an `ADD` statement
* The app's startup command should be defined using `CMD`
##### Example Dockerfile
FROM ruby:2.1.2
ENV PORT 3000
EXPOSE 3000
WORKDIR /app
ADD . /app
CMD ["bundle", "exec", "unicorn", "-p", "$PORT"]
[docker]: https://www.docker.com/whatisdocker/
[golang]: http://golang.org/