Merge pull request #1 from wvengen/feature/docker

Docker improvements
This commit is contained in:
Benjamin Meichsner 2015-05-04 14:42:18 +02:00
commit 6c2fefa2bf
6 changed files with 26 additions and 9 deletions

View file

@ -2,6 +2,7 @@
.idea
.sass-cache
log
config/database.yml
public/assets
public/system
tmp/*

View file

@ -1,12 +1,17 @@
#!/bin/sh
# Set test variables
export DATABASE_URL=mysql2://root:secret@mysql/test
# We use TEST_DATABASE_URL to make sure we don't accidentaly overwrite dev/prod db
unset DATABASE_URL; export DATABASE_URL
[ "$TEST_DATABASE_URL" ] && export DATABASE_URL="$TEST_DATABASE_URL"
export RAILS_ENV=test
# Start virtuals X environment to allow integration testing via firefox/iceweasel
export DISPLAY=:99
Xvfb :99 &
Xvfb $DISPLAY -nolisten tcp &
XVFB_PID=$!
# Start tests
rspec
# Cleanup
kill $XVFB_PID

View file

@ -5,6 +5,10 @@ Gratulations, if you read this file locally, you have successfully cloned the
foodsoft project from the git repository. Now you are only a few steps away
from trying it out and then jumping into development.
This document describes how to setup Foodsoft for development on your local system.
Alternatively, you [run Foodsoft using Docker](SETUP_DOCKER.md).
**System requirements**:
[RVM](https://rvm.io/rvm/install),
[Ruby 1.9.3+](https://www.ruby-lang.org/en/downloads/),

View file

@ -1,6 +1,6 @@
# Foodsoft on Docker
This document explains setup and using docker the foodsoft with docker.
This document explains setting up and using Foodsoft with Docker.
## Requirements
@ -23,9 +23,6 @@ to be pulled from docker registry and a lot dependencies needs to be installed.)
docker-compose run app rake foodsoft:setup_development
TODO: Right know this is not gonna work because of the new database
configuration via ENV variable. See Notes below.
## Usage
Start containers (in foreground, stop them with `CTRL-C`)
@ -40,6 +37,10 @@ Open a rails console
docker-compose run app rails c
Setup the test database
docker-compose run app rake db:setup RAILS_ENV=test DATABASE_URL=mysql2://root:secret@mysql/test
Run the tests
docker-compose run app ./bin/test
@ -64,5 +65,5 @@ docker commit -m "Updated rails" <Container ID> foodsoft_app
### Database configuration
TO make thins easier we use the ENV Variable DATABASE_URL. But to make this
work, the shouldn't be any config/database.yml file!
To make this easier we use the environment variable `DATABASE_URL`
(and `TEST_DATABASE_URL` when using the testing script).

View file

@ -13,6 +13,7 @@ app: &app
- DATABASE_URL=mysql2://root:secret@mysql/development
- REDIS_URL=redis://redis:6379
- QUEUE=foodsoft_notifier
- TEST_DATABASE_URL=mysql2://root:secret@mysql/test
resque:
<<: *app

View file

@ -58,6 +58,10 @@ end
def setup_database
file = 'config/database.yml'
if ENV['DATABASE_URL']
puts blue "DATABASE_URL found, please remember to also set it when running Foodsoft"
return nil
end
return nil if skip?(file)
database = ask("What kind of database do you use?\nOptions:\n(1) MySQL\n(2) SQLite", ["1","2"])
@ -110,6 +114,7 @@ def setup_secret_token
end
def start_mailcatcher
return nil if ENV['MAILCATCHER_PORT'] # skip when it has an existing Docker container
mailcatcher = ask("Do you want to start mailcatcher?\nOptions:\n(y) Yes\n(n) No", ["y","n"])
if mailcatcher === "y"
puts yellow "Starting mailcatcher at http://localhost:1080..."