Create the directory that will contain your project:
mkdir my-new-app
cd my-new-app
Create 3 blank files:
touch Dockerfile
touch docker-compose.yml
touch entrypoint.sh
Then copy/paste the corresponding files below.
You may want to replace my_new_app
by the name of your app in the file docker-compose.yml
.
docker-compose build
docker-compose run web bash
# you're now running a bash terminal inside the container
gem install rails
rails new -d postgresql .
exit
# you're now out of the container
In config/webpacker.yml
replace the key development/dev_server/host
with the value 0.0.0.0
(localhost
is the default value and we don't want it).
Replace your default database.yml file with the one provided here.
echo "/docker" >> .gitignore
echo "/bundle" >> .gitignore
docker-compose up
docker-compose run web bundle exec rails db:create