Skip to content

dagalloso/TemplateRoR6

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

Docker Template for Rails 6

This repository serves as an educational docker template over which to build a rails app.

Special thanks to @daleal. Edited and updated by @dagalloso._

Prerequisites

Getting Started

  • Copy files & change app name from example on Dockerfile, entrypoint.sh and docker-compose.yml to your app's name.

  • Create env file:

    touch .env
  • Create a rails app:

    docker-compose run web rails new . --force --no-deps --database=postgresql
  • Build the Docker image:

    docker-compose build
  • Get ownership of the files (on linux they are owned by root when created):

    sudo chown -R $USER: .
  • Connect the database (replace the content of config/database.yml with the following, change {example} with your app's name):

    default: &default
      adapter: postgresql
      encoding: unicode
      host: db
      username: postgres
      password:
      pool: 5
    
    development:
      <<: *default
      database: {example}_development
    
    test:
      <<: *default
      database: {example}_test
  • Create the database:

    docker-compose run web rails db:create
  • Run the app:

    docker-compose up
  • Or without logs

    docker-compose up -d

Useful Commands

  • Build the Docker image:

    docker-compose build
  • Start the server:

    docker-compose up
  • Or without logs

    docker-compose up -d
  • Stop the server:

    docker-compose down
  • Run rails command (command = rails ...):

    docker-compose run web `command`
  • Get ownership of files created by rails generate (on linux they are owned by root when created):

    sudo chown -R $USER:$USER .

Common errors

  • Couldn't connect do Docker daemon. Fix: run the command again with sudo at the beginning (Linux problem).
  • Error when creating the database. Fix: run docker-compose up, docker-compose down and run the command again.

Run an existing app

If your coworker already created the app and you want to run the existing up:

  • Clone the repo.
  • Build the containers (docker-compose build).
  • Create the database at your computer (docker-compose run web rails db:create).
  • Run the app (docker-compose up).

About

Template para una aplicación de RoR con Docker

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors