A very simple setup to work on Rails apps in a Docker container.
- Start the database:
docker-compose up -d mysql - Start the dev container:
docker-compose run --rm -p 3000:3000 rails_dev
rails new . --database db_type
Create a database and update the database connection options in config/database.yml.
- Install dependencies:
bundle install - Start the Rails service:
rails server -b 0.0.0.0
This will generate a model and the corresponding migration:
rails g model field1:type field2:type ...
To generate just a migration:
rails g migration migration_name
Run migrations:
rails db:migrate