Skip to content
Template that combines Sinatra, Sinatra::JSON, ActiveRecord and Docker into a reusable (micro)service.
Ruby
Branch: master
Clone or download
Latest commit 88d9657 Feb 12, 2016
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
app Add database schema Feb 9, 2016
docker Add Docker Jan 22, 2016
.gitignore Add databases to gitignore rules Feb 9, 2016
Dockerfile Add Docker Jan 22, 2016
LICENSE.txt Add basic documentation Jan 22, 2016
README.md Update README Feb 12, 2016
docker-compose.yml Link app to database Feb 12, 2016

README.md

Dockerize Sinatra

This project is indented as an example how to combine a Sinatra app serving a JSON API with both Docker and ActiveRecord. It has been developed as part of a blog series on this topic. You can read the articles here:

Sinatra

The Sinatra app is inside the directory /app. It consists of a Gemfile declaring its dependencies, a rackup file config.ru and the actual application itself in app.rb.

Docker

The application extends phusion's Docker image phusion/passenger-ruby22, and adds instructions to install the app and configure the bundled nginx server (see docker/vhost.conf).

It also uses a database that is provided by the official PostgreSQL image. Using docker-compose, both containers can be started simultaneously.

Usage

You can use docker-compose to start the application. The following command starts all containers:

$ docker-compose up

If you want to inspect the database, you can connect to it using psql:

psql -U sinatra sinatra

License

Copyright (c) 2016 Jan David Nose

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

You can’t perform that action at this time.