Docker Rails Template

screenshot of Docker Rails Template
rails

Docker Rails Template

A freshly updated version of "rails new", preconfigured to be run with Docker.

Overview

The content is about a Ruby on Rails app template. It provides instructions on how to set up and run the app locally, clone the repository, install Docker, and run the necessary commands. It also mentions features such as database restoration, running tests with RSpec, linting, contributing, and additional resources.

Features

  • Setup & Running Locally: Provides instructions for cloning the repo, installing Docker, and running necessary commands.
  • Running one of commands: Explains how to run a one-off command within the web service.
  • Restoring a database: Describes the process of restoring a database from an existing database dump file.
  • Tests: Mentioned that the template comes preconfigured with RSpec for tests and includes a GitHub Action to run them.
  • Linting: Informing that the app uses Standard for Ruby and includes a GitHub Action to check future commits.
  • Contributing: Indicates that the template was generated by Ruby-Starter-Kits/Docker-Rails-Generator and encourages reporting ideas there.
  • Usage: Encourages users to use the template as a starting point for their own Ruby on Rails projects.
  • Resources: Provides links to Ruby on Rails Guides, Ruby on Rails API Documentation, Heroku, and Docker-Rails-Generator.

Installation

To install and run the Ruby on Rails app locally, follow these steps:

  1. Clone down the repository.
  2. Install Docker.
  3. Compile the docker image and run the bin/setup file using the following command:
    docker-compose up --build
    
  4. This command will build the docker image, run bundle, yarn, and create the database.
  5. Once the setup is complete, navigate your browser to https://127.0.0.1:3000/ to see the site.

To run a one-off command, do the following:

  1. Run the command within the web service, for example:
    docker-compose run web <command>
    

To restore a database from an existing database dump file, follow the steps below:

  1. If you have an existing database dump in a file called latest.dump, turn on the postgres service in one terminal tab:
    docker-compose up postgres
    
  2. In a secondary tab, run the following command to restore the database:
    pg_restore --verbose --clean --no-acl --no-owner -h localhost -U myuser -d mydb "latest.dump"
    

To run tests with RSpec locally, use the command:

docker-compose run web rspec

To perform linting, the app uses Standard for Ruby. Future commits can be checked for coding standards using a GitHub Action.

If you have any ideas for improvement or contribution, report them to Ruby-Starter-Kits/Docker-Rails-Generator.

Summary

The article describes a Ruby on Rails app template that comes with preconfigured features for easy setup and development. It provides instructions for installing the app locally using Docker, running necessary commands, restoring databases, running tests with RSpec, and implementing linting. The article also encourages users to contribute and provides additional resources for further guidance and information.

rails
Ruby on Rails

Ruby on Rails, often referred to as Rails, is an open-source web application framework written in Ruby. Known for its convention over configuration and don't repeat yourself (DRY) principles, Rails simplifies and accelerates the development of database-backed web applications.

template
Templates & Themes

A template or theme refers to a pre-designed layout or structure that provides a basic framework for building a specific type of application or website. It typically includes good design, placeholder content and functional features, allowing developers to customize and fill in the details according to their specific needs.

docker
Docker

A website that uses Docker for containerization to streamline development, testing, and deployment workflows. This includes features such as containerization of dependencies, automated builds and deployments, and container orchestration to ensure scalability and availability.

webpack
Webpack

Webpack is a popular open-source module bundler for JavaScript applications that bundles and optimizes the code and its dependencies for production-ready deployment. It can also be used to transform other types of assets such as CSS, images, and fonts.