Part 1 of the Gemnasium workshop at dotRB2013.
Go to gemnasium/dotrb2013-docker and install the gemnasium/dotrb2013 Rails app using docker.
- make sure you have docker running, see dotrb2013-docker requirements
- install dotrb2013-docker
- create a GitHub application, see dotrb2013 for the how-to
- create a
.env
file with your host IP and GitHub client credentials - run
make pull
and get the docker images (please wait) - run
./bin/postgresql-start
and./bin/rails-start
You should then be able to:
- visit the root URL of the Rails app
- sign in using your GitHub account
- add a pull request URL
- see the pull resquest metadata after reloading the page (async job)
- connect to the admin interface and explore the data model
Warning! Admin sessions seem to conflict with normal user sessions.
Warning! Don't forget that rails-start
and postgresql-start
scripts from dotrb2013-docker create new containers each time you call them!
- play with the Rails app to fill the database
- commit the postgresql container to
my-postgreql
- create even more data
- stop the postgresql container
- start a new postgresql container from your
my-postgresql
image
Commands
docker commit
docker run
docker start
Tips
- modify the
bin/postgresql-start
script and change the name of the docker image docker commit
needs some specs to re-run the image, use-run='{"Cmd": ["/start", "postgres"], "PortSpecs": ["5432"]}'
Warnings
- your image name must contain "postgresql", see
bin/postgresql-info
script
- create a mailtrap account
- create an inbox on mailtrap for the rails app
- run the rails container in "console mode"
- try your mailer
- commit the container to
my-rails
image
To try your mailer:
- add a pull request that has been already merged
- connect to the
/admin
interface and reset themerged_at
date - visit
/admin/resque
, "schedule" tab - enqueue now: update all pull requests
- enqueue now: send emails
Obviously, the mailer config should come from somewhere: the repo, some environment variables, some configuration server, etc.
Tips
- modify the
bin/rails-start
script and change the name of the docker image - when running the container in "console mode", run
/rails/start-production
as root to get your app running
- run the rails app
- do something wrong, call a route that does not exist
- copy the log file from the container to the host OS (container is still running)
- production logs live in
/rails/log/production.log
inside the container
Commands
docker cp
Tips
docker cp 1234:/xyz .
to copy/xyz
from the container1234
to the host operating system
We can edit the source code of the Rails app using vim inside the container. Or we can push the code using git. But this is not really convenient when working on the source code. Every developer wants her/his own development tools!
- copy the
/rails
directory from your container to the host operating system - edit the
rails-start
script and modifydocker run
command line: make a mount - edit the source code on the host OS
- run the rails container with
rails-start
- you should be able to see your modifications
Tips
docker run -v /tmp:/root myImage
in order to mount/tmp
from the host machine as/root
within the image
The rails app uses sqlite for both development and test environments. But we could use our "postgresql" container everywhere!
- go into the rails container
- update the
config.yml
to match production config everywhere
It's easy to rollback:
- to an empty database for our test suite
- to a well-know dataset for our dev environment