Planning to dockerize your Ruby on Rails dev environment? Here's how you can easily set up your Rails project with Lando.
Read the full article Dockerize Ruby on Rails with Lando on Jigarius.com.
Here's how you can use this repository. Please note that this is intended to be used for local development only and not for production.
- Follow the steps mentioned under Existing app or New app.
- This will ensure that you have a Rails app.
- In
config/database.yml
to update database credentials.- See
lando/appserver/example.database.yml
.
- See
- In
config/environments/development.rb
allow requests from*.lndo.site
.- Add
config.hosts << /.*\.lndo\.site/
.
- Add
- Run
lando rake db:create
to create databases. - Run
lando rake db:migrate
to execute migrations. - Run
lando rails-server
to start therails server
.
Voila! Your Rails app should now be running at rails.lndo.site
.
If you have an existing Rails app,
- Copy the
.lando
file to the root of your Rails project. - Update your
config/database.yml
to use the correct credentials.- See
lando/appserver/example.database.yml
.
- See
cd
into the root directory of your project.- Run
lando start
(you must have Lando installed).
- Clone/download this repository.
cd
into the code directory.- Modify the following config as per your needs:
- Project name in the
.lando.yml
- Ruby version (for advanced users).
- in the
.lando.yml
file. - in the
Gemfile
. - in the
lando/appserver/Dockerfile
.
- in the
- Rails version in the
Gemfile
(for advanced users).
- Project name in the
- Create a new Rails app
lando rails new --database=postgresql /app
.- You can add other flags, e.g.
--minimal
. - The Rails install path must be
/app
.
- You can add other flags, e.g.
Run the command lando
to see a list of available commands.