- First clone the project
git clone https://github.com/Mashpy/rails-7-docker-template-with-mysql.git
- Rename the project name as your wish
mv rails-7-docker-template-with-mysql your_project_name
- Change directory -
cd your_project_name
- Update your rails version on the Gemfile -
source 'https://rubygems.org'
gem 'rails', '7.0.3'
- Update Ruby version on Dockerfile -
FROM ruby:3.1.2-slim
- Now install new rails app -
docker-compose run app rails new . --force --database=mysql --skip-bundle
- Build the docker image -
docker-compose build
- Update database details on config/database.yml file.
default: &default
adapter: mysql2
encoding: utf8
pool: 5
username: root
password: "root"
host: mysql
development:
<<: *default
database: dev
test:
<<: *default
database: dev
- Run -
docker-compose up
- Browse http://localhost:3000