Coder Social home page Coder Social logo

rails_template's Introduction

Description

This is a basic scaffolded Rails project using Docker with Ruby 2.6.5, Rails 5.2.4, and Postgres 12.1. This project can be used in lieu of installing Ruby, Rails and Postgres on your machine. When you run docker-compose up, Docker will create two containers on your machine: a Ruby/Rails environment running the local server and a Postgres container where your database is stored.

Windows Users

You will need to uncomment the following line in Dockerfile for the entrypoint.sh script to run correctly:

RUN sed -i -e 's/\r$//' /usr/bin/entrypoint.sh

This line switches the line ending format so it works correctly with Windows. (Note that if the line above is uncommented, the script won't run correctly with Mac machines.)

Running Rails and Postgres Servers

  • Run docker-compose up to run the local server at localhost:3000. However, if you go to localhost:3000, you will see the DB is not set up yet.

Running Shell Commands

To access a shell environment to run rails c, run migrations, or run other rake and rails tasks such as rails routes, you'll need to do the following.

Run the following command in the root directory of the project:

$ docker-compose run web sh

It's not necessary for the containers to be running (with $ docker-compose up).

This will open a shell where you can run any commands in the web application's environment. This includes the following commands:

  • $ bundle exec rake db:create (and any other Rake commands)
  • $ rails routes and $ rails c (as well as any other Rails commands)
  • $ bundle exec rspec (to run tests)
  • $ irb (if you just need a basic Ruby REPL)

What if I want to add more gems to my project?

You'll need to complete the following steps:

  • First, add the gems to the project.

  • Run docker-compose run web bundle install. This will bundle the new gems.

  • Next, run docker-compose up --build. This will rebuild the project.

To read Docker's documentation on running projects using Ruby and Rails, see Quickstart: Compose and Rails.

rails_template's People

Contributors

hagoodwi92 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.