Rails + MySQL environment settings for development.
- Copy this repository to project directory.
- Create and edit env file
cp common.env.sample common.env
# and edit
- Build.
docker-compose build
- Create Rails project on working directory of app.
docker-compose run --rm app rails new . --force --database=mysql --skip-bundle
# with Webpacker & React
docker-compose run --rm app rails new . --force --database=mysql --skip-bundle --webpack=react
- Edit app/config/database.yml.
password: <%= ENV.fetch("MYSQL_ROOT_PASSWORD") %>
host: db
# and other settings like charset
- Install gems for Rails
docker-compose run --rm app bundle install
- Create db
docker-compose run --rm app rails db:create
- Up
docker-compose up
- Done
Updating Gemfile and docker-compose build
doesn't work because image's bundle directory is hidden by the mounted volume when the container runs.
Do docker-compose run --rm app bundle install
to install gems into the mounted volume.