Example of using Ruby on Rails with docker compose.
A simple example of using Docker Compose for developing and deploying Ruby on Rails applications.
Read the full article on jigarius.com.
Follow the steps mentioned under existing app or new app depending on your
situation. That will ensure that the ror
directory is in order. After that,
follow these steps:
.env.example
to .env
and modify (if required).config/database.yml
based on .docker/ror/example.database.yml
.docker-compose build
docker-compose up
docker-compose exec web rake db:create
Cool! Now your Rails app should be available at localhost:3000.
ror
directory.ror
directory.
Gemfile
should be at ror/Gemfile
.If you want to start with a Rails app from scratch,
Gemfile
: You can base this on .docker/ror/example.Gemfile
.Gemfile.lock
: An empty file.rails new
command as needed.
docker-compose run --no-deps web rails new . --force --database=postgresql
--minimal
flag.Here are some helpful commands.
docker-compose start
: Starts app containers.docker-compose stop
: Stops app containers.rake -T
: For some other helpful commands.See docker compose docs for further info on Docker Compose.