Rails7 Startkit Save

Launch Rails with 1 shell command!

Project README

Rails 7. Start Kit

Rails 7. Start kit. v2.1

Install and Run Ruby on Rails in Minutes!

Copy & Paste in your terminal

❤️ Linux / MacOS

git clone https://github.com/the-teacher/rails7-startkit.git && \
  cd rails7-startkit && \
  ruby bin/setup

💙 Windows

git clone https://github.com/the-teacher/rails7-startkit.git & cd rails7-startkit & ruby bin/setup

What Is That?

Rails App in a Docker container with some popular preinstalled tools.

Why Do I Need It?

Save hours, days or weeks on setting up a typical Rails app.

What Cases for Using It?

  • You start new Rails project
  • You need a playground for experiments
  • You learn Rails and related technologies
  • You teach people or record videos about Rails
  • You are going to write a new article about Rails

How it works

Rails 7. Start Kit

What Is Under the Hood?

Logotype Description Why it was added

Main

docker Docker Helps to keep all required services in containers. To have fast and predictable installation process in minutes. Docker Images are here.
ruby Ruby 3.2 Most recent version of Ruby
rails7 Rails 7 Most recent version of Rails
pgsql PostgresSQL Most popular relational database

Cache and Delayed Jobs

redis Redis In-memory data store. For caching and as a dependency of Sidekiq
sidekiq Sidekiq Job Scheduler and Async Tasks Executor. Can be used as a stand alone tool or as ActiveJob backend
whenever whenever Linux Cron based periodical tasks
elastic Elasticsearch The world’s leading Search engine
chewy Chewy Ruby Connector to Elasticsearch

Front-end

bootstrap Bootstrap Old but Gold Framework for Web
import-maps ES Build An extremely fast bundler for the web
import-maps Import Maps Rails' recommended way to process JavaScript
sprockets Sprockets Rack-based asset packager

Application Configuration

gem dotenv-rails gem "dotenv" ENV variables management tool
gem config gem "config" Configuration management tool

Application Level

puma Nginx Web Server. Reverse Proxy. Load Balancer. Caching, Streaming etc.
puma Puma Application Web Server. To launch Rails app
devise Devise Authentication solution for Rails + Emails confirmations
ActiveStorage ActiveStorage Default Cloud Storage Solution for Rails
faker Faker Fake data for development and testing
kaminari Kaminari Pagination solution
sanitize Sanitize Sanitization of a dangerous users' input
letter_opener mailcatcher Email previewer for development

Code Quality

rspec RSpec Testing Framework for Rails
rspec Rubocop Ruby static code analyzer (a.k.a. linter) and formatter.
breakman Breakman Static analysis tool | Security Vulnerabilities.
rspec SimpleCov Code coverage for Ruby (and Rails)

What I'm going to add...

Logotype Description Why it was added
devise Devise Login with Facebook and Google

All trademarks, logos and brand names are the property of their respective owners.

Installation and Running

Copy & Paste in your terminal

❤️ Linux / MacOS

git clone https://github.com/the-teacher/rails7-startkit.git && \
  cd rails7-startkit && \
  ruby bin/setup

💙 Windows

git clone https://github.com/the-teacher/rails7-startkit.git & cd rails7-startkit & ruby bin/setup

You will see something like that:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Rails 7. StartKit
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
What was done:
1. Pull all required Images

2. Launching ElasticSearch Container
3. Launching Mailcatcher Container
4. Launching PgSQL Container
5. Launching Redis Container
6. Launching Rails Container

7. Correcting Permissions for Linux
8. Installing Gems
9. Turn off some ElasticSearch settings
10. Prepare Database (Create, Migrate, Create Seeds)
11. Indexing Article Model

12. Quality: Rubocop
13. Quality: RSpec with SimpleConv
14. Quality: Breakman

15. Yarn: Install Node Packages
16. Yarn: Build JS/CSS Assets
17. Precompile Assets

18. Launching Sidekiq
19. Launching Rails App with Puma

20. Visit Rails App: http://localhost:3000
21. Visit Mail Service: http://localhost:1080
22. Visit ElasticSearch: http://localhost:9200
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Welcome to RAILS 7!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

bin/ commands

❤️ :warning: bin/exec - Linux and MacOS users can skip using ruby

💙 :warning: ruby bin/exec - Windows users should use ruby explicitly

From the root of the project

Command Description
Most important
ruby bin/setup Download images, run containers, initialize data, launch all processes.
ruby bin/open Get in Rails Container
rubyc bin/exec [CMD] Execute a command ([CMD]) from Rails7StartKit module

bin/open command

Command Description
Get in a container
ruby bin/open [NAME] Get in a Container. [NAME]

[NAME] Values: rails,psql, redis, elastic, mailcatcher.

Default value is: rails.

bin/exec command

All Possible Module Methods
  • breakman
  • cache
  • check_docker!
  • check_docker_compose_v2!
  • check_docker_running!
  • chewy_index
  • chewy_reset
  • container_bash_exec
  • container_exec
  • containers_information
  • cron_start
  • cron_stop
  • docker_compose
  • init_nvm
  • log_puma
  • log_server
  • log_sidekiq
  • print_methods
  • prompt!
  • puma_dev_start
  • puma_restart
  • puma_start
  • puma_stop
  • rails7_header
  • rails7_ready
  • rails7_startkit_greetings!
  • rails_assets_precompile
  • rails_db_migrate
  • rails_db_prepare
  • rails_install_gems
  • reset
  • restart
  • restart_all
  • rspec
  • rspec_with_cov
  • rubocop
  • rubocop_fix
  • setup!
  • sidekiq_start
  • sidekiq_stop
  • start
  • start_all
  • start_all_containers
  • status
  • stop
  • stop_all
  • stop_all_containers
  • system!
  • turn_off_elastic_settings
  • whenever_show
  • whenever_start
  • whenever_stop
  • yarn_build
  • yarn_install
Command Description

:arrow_right: Execute

ruby bin/exec [CMD] Execute a command ([CMD]) from Rails7StartKit module

:arrow_right: Start/Stop/Restart

ruby bin/exec start Start processes in rails container
ruby bin/exec stop Stop processes in rails container
ruby bin/exec restart bin/exec stop + bin/exec start
ruby bin/exec start_all Start processes and containers
ruby bin/exec stop_all Stop processes and containers
ruby bin/exec restart_all bin/exec stop_all + bin/exec start_all

:arrow_right: Helpers

ruby bin/exec status To see running containers and launched services
ruby bin/exec cache Toggle caching in development and restart web server
ruby bin/exec index Run Search engines indexation
ruby bin/exec reset Reset data of services in ./db folder

Prerequisites

On your host you have:

  • Any version of Ruby
  • Any version of Git
  • Any version of Docker

Conventions and Agreements

Show details

For demonstration, education and maintainance purposes I use a bit unsusual approach to name some files.

I _UNDERSCORE and UPPERCASE some files and folders to move them on the top of a folder and to make them more visible and to highlight their importance.

Data

  • All services' data related folders are placed in ./db
  • All folders are UPPERCASED
./db
├── ELASTIC
├── PGSQL
└── REDIS

Configuration Files

  • All services' configurations are placed in ./config
  • All configs are _UNDERSCORED and UPPERCASED
./config
├── _CONFIG.yml
├── _PUMA.rb
└── _SIDEKIQ.yml

Initialazers

  • All services' initializers are placed in ./config/initializers
  • All files are _UNDERSCORED and UPPERCASED
./config/initializers/
├── _CHEWY.rb
├── _CONFIG.rb
├── _REDIS.rb
└── _SIDEKIQ.rb

Rails user

Show Details

As a user to own files and run Rails inside a container I use

user:group => lucky:lucky => 7777:7777

If you would like to run the project on a linux environment then:

  • create group lucky (7777) and user lucky (7777)
  • run the project with RUN_AS=7777:7777 option

Questions and Answers

What is an idea of this project?

For many years Rails gives you freedom to choose development tools. Different databases, different paginators, different search engines, different delayed job solutions.

It is great. But all the time you need to choose something and install it from scratch.

I think I did my choice about many solutions and tools.

I want to install my minimal pack of tools now and reuse my StartKit every time when I start a new project.

With Docker I can roll out my minimal application with all required preinstalled tools in minutes, not in hours or in days.

Why did you create this project?

I didn't work with Rails last 4 or 5 years. I wanted to learn new approaches and techniques. I found that there is still no a simple way to setup a blank app with most popular tools.

So. Why not to make my own playground?

How do you choose technologies for the StartKit?

I use tools that I like or want to learn.

I use tools that I think are the most popular ones.

It looks good for development. What about production?

I'm not a DevOps, but I have a vision how to deploy this code to production.

Right now it is not described somehow. It is in my plans.

TODO

Show details
  • Nginx
  • Production roll up
  • Action Cable Link

Sponsorship

These amazing companies and teams support the project:

JetBrains.com Hoodies.team

License

MIT License. 2023. Ilya N. Zykin

Open Source Agenda is not affiliated with "Rails7 Startkit" Project. README Source: the-teacher/rails7-startkit

Open Source Agenda Badge

Open Source Agenda Rating