Adding this alias to your shell profile will be very useful
alias dweb='docker-compose run --rm web'
-
Copy files to your-new-project
Dockerfile
docker-compose.yml
- Gemfile
- Gemfile.lock
-
Change in
docker-compose.yml
the bundle/image name to beyournewproject_web
-
Commit with "I'm going to write Rails in Docker"
-
docker-compose build
-
Commit again
git add . git commit -m "Built my image with rails"
-
Initialise your new Rails project with
dweb rails new .
You will be asked if to overwrite
Gemfile.lock
- what do you think? ;-) -
All further commands use with
dweb
prefix, i.e.dweb rails c
-
Further initial steps which are normal for Rails writing:
dweb bundle
- to install basic gems of the newly created app
-
Serve the app with
docker-compose up
, see it at http://localhost:3000