This repository contains an example dockerized Ruby on Rails development configuration based on the Ruby on Whales blog post.
See the example folder.
We also provide an interactive generator for Rails apps to quickly setup a dockerized environment for your app. Just run the following command and follow the instructions:
bundle exec rails app:template LOCATION='https://railsbytes.com/script/z5OsoB'You can also run it via Ruby Bytes (so you can dockerize a Rails app without installing it on your host machine):
rbytes install https://railsbytes.com/script/z5OsoBTo persiste Pry or IRB history, you must configure them to store it in the history volume.
For IRB, add the following to your .irbrc file:
IRB.conf[:SAVE_HISTORY] = 10_000 # Maximum number of lines to save in history
IRB.conf[:HISTORY_FILE] = ENV.fetch("IRB_HISTFILE", "#{ENV["HOME"]}/.irb-history")Then, in the compose.yml, specify the IRB_HISTFILE environment variable:
x-backend:
environment:
# ...
IRB_HISTFILE: /usr/local/hist/.irb_historySimilarly, for Pry, add the following to your .pryrc file:
Pry.config.history_save = true
Pry.config.history_file = ENV.fetch("PRY_HISTFILE", "#{ENV["HOME"]}/.pry-history")Then, in the compose.yml, specify the PRY_HISTFILE environment variable:
x-backend:
environment:
# ...
PRY_HISTFILE: /usr/local/hist/.pry_history- System of a test (setting up system tests with Docker)
- Vite-alizing Rails (more about using Vite with Rails and Docker)
- Faster RuboCop runs for Rails
- Terraforming Rails
The code is available as open source under the terms of the MIT License.
