Dockerized Rails app using ActionCable, Elasticsearch, Sidekiq and Yarn
Clone or download
Latest commit d370eb4 Dec 17, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
app Make Rubocop happy Sep 16, 2018
bin Some fixes from "rails new" May 2, 2018
config Bump 1.9.3 Dec 8, 2018
db Postgres: Use JSON column for storing Clip#image_data Apr 7, 2018
docker 🐳 Use sh instead of bash Apr 22, 2018
lib Remove gem "responders" to keep it simple Mar 20, 2018
log New Rails app Oct 29, 2016
public robots.txt: Disallow all Jun 12, 2017
spec Elasticsearch: Fix specs Nov 17, 2018
storage ⬆️ Upgrade Rails to 5.2.1.rc1 Jul 31, 2018
tmp New Rails app Oct 29, 2016
vendor Some fixes from "rails new" May 2, 2018
.babelrc Use ReactJS with gem "react-rails" (#165) Jan 14, 2018
.codeclimate.yml Make Rubocop happy again Apr 16, 2018
.dockerignore 🐳 There is more to ignore Jul 27, 2018
.eslintignore Codeclimate config May 20, 2017
.eslintrc.yml Codeclimate config May 20, 2017
.gitignore ⬆️ Upgrade Rails to 5.2.1.rc1 Jul 31, 2018
.gitlab-ci.yml GitLabCI: Add webhook to Portainer Sep 17, 2018
.postcssrc.yml Use ReactJS with gem "react-rails" (#165) Jan 14, 2018
.rspec Update RSpec config May 8, 2017
.rubocop.yml ⬆️ Upgrade gem "rubocop" to 0.60.0 Oct 27, 2018
.travis.yml 🐳 Avoid image name conflicts Aug 17, 2018
.yarnclean Add .yarnclean May 17, 2018
Brewfile Allow to use Minio as S3 replacement in dev mode Jan 4, 2018
Dockerfile ⬆️ Upgrade Ruby to 2.5.3 Oct 20, 2018
Gemfile ⬆️ Upgrade Rails to 5.2.2 Dec 5, 2018
Gemfile.lock ⬆️ Upgrade gem "autoprefixer-rails" to 9.4.3 Dec 17, 2018
LICENSE 2018 Jan 2, 2018
Procfile.development Use ReactJS with gem "react-rails" (#165) Jan 14, 2018 Readme: Image size is 120MB Sep 16, 2018
Rakefile Add rake task "rubocop" and add it to default Dec 30, 2017
coffeelint.json Codeclimate config May 20, 2017 New Rails app Oct 29, 2016
docker-compose.production.yml ⬆️ Upgrade "elasticsearch" to 6.5.2 Dec 8, 2018
docker-compose.test.yml ⬆️ Upgrade "elasticsearch" to 6.5.2 Dec 8, 2018
docker-compose.yml ⬆️ Upgrade "elasticsearch" to 6.5.2 Dec 8, 2018
package.json ⬆️ yarn upgrade Nov 13, 2018
yarn.lock ⬆️ yarn upgrade Dec 17, 2018


Build Status Code Climate Issue Count Depfu Greenkeeper badge

Simple Rails 5.2 application to demonstrate using Docker for production deployment. The application is a very simple kind of CMS (content management system) allowing to manage posts. Beside the boring CRUD functionality it has some non-default features.

This project aims to build a lean Docker image for use in production. Therefore it's based on the official Alpine Ruby image, uses multi-stage building and some optimizations that I described in my blog. This results in an image size of ~120MB (including the large wkhtmltopdf binary).



This project demonstrates my way of building Rails applications. The techniques used to build the app should not be considered as "best practice", maybe there are better ways to build. Any feedback would be appreciated.

Multi container architecture

There is a separate docker-compose.yml for every environment: development, test and production. The whole stack is divided into multiple different containers:

  • app: Main part. It contains the Rails code to handle web requests (by using the Puma gem). See the Dockerfile for details. The image is based on the Alpine variant of the official Ruby image and uses multi-stage building.
  • worker: Background processing. It contains the same Rails code, but only runs Sidekiq
  • db: PostgreSQL database
  • elasticsearch: Full text search engine
  • memcached: Memory caching system (used from within the app via the Dalli gem)
  • redis: In-memory key/value store (used by Sidekiq and ActionCable)
  • backup: Regularly backups the database as a dump via CRON to an Amazon S3 bucket

For running tests using RSpec, there is an additional container:

  • selenium: Standalone Chrome for executing system tests containing JavaScript

Check it out!

To start up the application in your local Docker environment:

git clone
cd docker-rails
docker-compose build
docker-compose run app yarn install
docker-compose up

Wait some minutes while the database will be prepared by fetching articles from Wikipedia. Then, navigate your browser to http://[DOCKER_HOST]:[DOCKER_PORT].

Sign in to the admin account:

  • Username:
  • Password: secret


Tests / CI

On every push, the test suite (including RuboCop checks) is run in public on Travis CI and in private on Gitlab CI.

On every successful Travis build, a new Docker image is pushed to Docker Hub.

Production deployment

The Docker image build for production is different from development or test. It includes precompiled assets only (no node_modules and no sources). The spec folder is removed and the Alpine packages for Node and Yarn are not installed.

The stack is ready to host with nginx proxy and letsencrypt-nginx-proxy-companion. See docker-compose.production.yml for example setup.


A demo installation is set up on