Skip to content

Commit

Permalink
Add documentation for getting set up to use Docker
Browse files Browse the repository at this point in the history
Added a section to the README documenting how to get started using
Docker and set up a `bin/docker_setup` script to make this easier.
I've made modifications to the /config/database.yml.example so that it can simply be
copied over and it will work for either development set up.
  • Loading branch information
keiththomps committed Oct 18, 2016
1 parent a9640d4 commit 57dd700
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 2 deletions.
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,27 @@ In order to activate caching in development you can add `CACHE_DEVELOPMENT="anyt
[foreman]: http://ddollar.github.io/foreman/
[pow]: http://pow.cx

Getting Started with Docker
---------------------------

This repository comes equipped to be run within Docker, but this requires a few more local dependencies. For instructions on installing and getting started with Docker go [here](https://www.docker.com/products/docker). You'll also need [`docker-compose`](https://docs.docker.com/compose/overview/), but it will be installed for you through Docker for Mac or Windows.

This repository comes equipped with a self-setup script for using Docker:

% ./bin/docker_setup

On first boot you'll also need to create your database, for that use:

% docker-compose run --rm app rake db:create db:migrate

After setting up, you can run the application and dependencies using [docker-compose]:

% docker-compose up -d

If your Docker host is running on `localhost` then you should be able to use pow, otherwise you'll need to connect to it via:

http://DOCKER_IP:7000

Feature Flags
-------------

Expand All @@ -71,7 +92,7 @@ Single Tenant Mode: Initialize application in single tenant mode. Disabled by de

Usage:

To use the single tenant mode, you can add SINGLE_TENANT_MODE to your enviroment variables with the value `true`. On development you can set this in your .env with `SINGLE_TENANT_MODE=true` and restart foreman. On heroku it's under the `Config Variables`.
To use the single tenant mode, you can add SINGLE_TENANT_MODE to your enviroment variables with the value `true`. On development you can set this in your .env with `SINGLE_TENANT_MODE=true` and restart foreman. On heroku it's under the `Config Variables`.
The first user in single tenant mode can be created by a rake task `rake create_user`. We'll ask you for your credentials.

Guidelines
Expand Down
17 changes: 17 additions & 0 deletions bin/docker_setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env sh

# Exit if any subcommand fails
set -e

# Set up database.yml
if [ ! -f config/database.yml ]; then
cp config/database.yml.example config/database.yml
fi

# Set up configurable environment variables
if [ ! -f .env ]; then
cp .sample.env .env
echo "POSTGRES_HOST=db" >> .env
echo "POSTGRES_USER=hours" >> .env
echo "POSTGRES_PASSWORD=secure_password" >> .env
fi
3 changes: 3 additions & 0 deletions config/database.yml.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
development: &default
adapter: postgresql
host: <%= ENV["POSTGRES_HOST"].presence || "localhost" %>
username: <%= ENV["POSTGRES_USER"] %>
password: <%= ENV["POSTGRES_PASSWORD"] %>
database: hours_development
encoding: utf8
min_messages: warning
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ services:
volumes:
- .:/usr/src/app
ports:
- "8080:8080"
- "7000:8080"
depends_on:
- db

0 comments on commit 57dd700

Please sign in to comment.