Skip to content

lacf95/railsdocker

Repository files navigation

Ruby on Rails docker compose bootstrap

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.

Requirements.

NOTE: Docker desktop for macOS installs Docker compose and doesn't require Rootless mode.

Installation and usage.

  1. Clone this repo:
git clone https://github.com/lacf95/railsdocker
  1. Change to the repo's directory:
cd railsdocker
  1. Run new to create a new Rails app:
./new ~/rails_app_name
  1. Change to the created app directory:
cd ~/rails_app_name
  1. Build your new app services:
bin/docker build
  1. 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
  1. Finally, start all services:
bin/docker up

Commands

New command

The new command can receive one argument:

  1. The path for the new project (required).

And two options:

  1. -r to set the Ruby version.
  2. -s to set the Rails version.
  3. -j to set the Javascript approach.

Project installed commands

Build command

The bin/docker build command builds and pulls all Docker compose required images; it can receive one option --no-cache to build from zero.

Up command

The bin/docker up starts all Docker compose services; it can receive one option --daemon to run in the background.

Run command

The bin/docker bash [service:-app] connects to the running container, if not possible starts a new one.

Run command

The bin/docker attach [service:-app] attach to the running container's STDIN, STDOUT, and STDERR, useful when prying on your server.

Down command

The bin/docker down command stops and remove service containers.

About

Ruby on Rails docker compose bootstrap

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published