Creates a Ruby on Rails application with configured Docker compose.
It comes with Postgresql and Redis services. Also, uses volumes for:
- Database persistence.
- File sharing between the host and container.
- Cached gems between builds.
- Script history
.bash_history
- Script configuration
.bashrc
.
- Install Docker version
18.06.0+
or newer. - Install Docker compose.
- Enable Docker Rootless mode.
NOTE: Docker desktop for macOS installs Docker compose and doesn't require Rootless mode.
- Clone this repo:
git clone https://github.com/lacf95/railsdocker
- Change to the repo's directory:
cd railsdocker
- Run
new
to create a new Rails app:
./new ~/rails_app_name
- Change to the created app directory:
cd ~/rails_app_name
- Build your new app services:
bin/docker build
- Run your app so you can configure the database, and install webpacker (optional):
bin/docker bash # Or bin/docker bash app
bin/rails db:prepare
bin/rails webpacker:install
exit
- Finally, start all services:
bin/docker up
The new
command can receive one argument:
- The path for the new project (required).
And two options:
-r
to set the Ruby version.-s
to set the Rails version.-j
to set the Javascript approach.
The bin/docker build
command builds and pulls all Docker compose required images; it can receive one option --no-cache
to build from zero.
The bin/docker up
starts all Docker compose services; it can receive one option --daemon
to run in the background.
The bin/docker bash [service:-app]
connects to the running container, if not possible starts a new one.
The bin/docker attach [service:-app]
attach to the running container's STDIN, STDOUT, and STDERR, useful when prying on your server.
The bin/docker down
command stops and remove service containers.