Docker with a Rails Application
Docker is a lightweight containerization platform that makes deploying software easy. Docker images are created from instructions listed in Dockerfiles and Docker Compose (formerly Fig) makes it easy to build multi-container Docker applications. This is great because it compartmentalizes all of the different services required by the application. This separation of concerns makes it extremely easy to add or remove services to the app and it makes updating a specific service a breeze. Developing with Docker also makes it easy to onboard new engineers, as setting up their local environments will all be automated with the single requirement of having Docker installed on their local machine. Docker also guarantees that your development and production environments will be identical across all machines so deploying code to production will not be such a headache.
Docker will need to be installed on your local machine; download instructions can be found here. The installation will include Docker Engine, Docker Cli client, Docker Compose, and Docker Machine. This tutorial will use version 2 of the Compose File Format which requires Compose 1.8.0 and Docker Engine 1.10.0 or later. This tutorial also assumes basic familiarity with Docker and docker-compose commands. If you are unfamiliar with Docker, or you just need a refresher, you can find a great tutorial for Docker here and a Docker Compose tutorial here. If you would like to code along, the repository with the source code prior to adding any Docker related files can be cloned from here.
The application we will be configuring will use Rails 5, Postgres, Redis, Sidekiq, and nginx. We will start small and just get the application and database wired up. Then we will add Redis and Sidekiq. Once all of those services are working, we will add nginx to buffer requests and reponses between users and the rails application.
In lieu of a codewars challenge please get docker installed, review docker and docker-compose commands, and get the app working locally if you would like to code along. If you have any issues please email and I can offer some assistance.