Skip to content

Allows easy creation of a rails environment with Docker-compose (Ruby 2.5 + Postgres 9.6)

License

Notifications You must be signed in to change notification settings

gfauredumont/docker_rails

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

docker_rails

This Docker/compose set allows a easy creation of a Ruby on Rails environment (latest Rails + Postgres 9.6.6)

=> If you need a mail catcher, just uncomment the corresponding lines in the compose file (and modify the rails configuration accordingly)

Environment based on:

  • Ruby 2.5
  • Rails (latest if not specified)
  • PostgreSQL 9.6.6

REMEMBER to add the .env.web files to your .gitignore file !!

The Postrgres volume is used to allow saving DB data even when containers are stopped

The Dockerfile is a genric one, please change the name of the project before starting the container:

=> Replace project_name with your actual project name in Dockerfile => Do the same in docker-compose.yml

First step is to build the environment and install rails (or anything else...) before rebuilding the complete environment:

    # Build the image with just the smallest Ruby image and postgres
    docker-compose build
    # Now create the Rails project with desired options
    docker-compose run web rails new . --force --database=postgresql
    # Now that the Gemfile has been populated, we can build the final image (bundling is done in the Docker image building)
    docker-compose build
    # From now on, building it is only needed when the Gemfile changes
    # Start the container like this
    docker-compose up

Project is not already created so you can benefit from later Rails improvements

Linux specific:

From host, to 'get ownership back' for the generated files (with a rails generate for instance), this command finds all files owned by root in the current directory and chown them back to given_user: (Postgres directory will stay own by root, this is normal !)

    find . -user root | xargs sudo chown given_user:given_user

About

Allows easy creation of a rails environment with Docker-compose (Ruby 2.5 + Postgres 9.6)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages