muhammadyana / rails7-startkit

Rails7 StartKit. Launch App in minutes!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rails 7. Start Kit

Rails 7 App with Preinstalled Tools is Ready in Minutes!

Why?

Usually It is difficult and time consuming to setup a typical Rails environment from scratch.

Since now if you have Ruby and Docker then you have working Rails environment in about 5 minutes without any manual efforts.

What is under the hood?

Logotype Description Why it was added
docker Docker Helps to keep all required services in containers. To have fast and predictable installation process in minutes
pgsql PostgresSQL Most popular relational database
ruby Ruby 3.2 Most recent version of Ruby
rails7 Rails 7 Most recent version of Rails
puma Puma Application Web Server. To launch Rails app
gem config gem "config" Configuration management tool
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
elastic Elasticsearch The world’s leading Search engine
chewy Chewy Ruby Connector to Elasticsearch
import-maps Import Maps Rails' recommended way to process JavaScript
faker Faker Fake data for development and testing
sanitize Sanitize Sanitization of a dangerous users' input
kaminari Kaminari Pagination solution

What I'm going to add...

Logotype Description Why it was added
devise Devise Authentication solution for Rails
devise Devise Login with Facebook and Google
devise Devise and Action Mailer Sending emails for account confirmations
letter_opener mailcatcher Email previwer for development
whenever whenever Linux Cron based periodical tasks
rspec RSpec Testing Framework for Rails
rspec Rubocop Ruby static code analyzer (a.k.a. linter) and formatter.

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

Prerequisites

On your host you have:

  • Ruby 2+
  • Docker
  • Git

How to start?

ONE!

git clone https://github.com/the-teacher/rails7-startkit.git

TWO!

cd rails7-startkit

THREE!

bin/setup

You will see something like that:

1. Launching PgSQL container
2. Launching ElasticSearch Container
3. Launching Rails container
4. Installing Gems. Please Wait
5. Create DB. Migrate DB. Create Seeds
6. Launching Redis Container
7. Indexing Article Model
8. Launching Rails App with Puma
9. Launching Sidekiq
10. Visit: http://localhost:3000
Index Page of the Project rails7-startkit

bin/ commands

From the root of the project

Command Description
bin/setup Download images, run containers, initialize data, launch all processes.
bin/open Get in Rails Container (`rails` by default)
bin/open rails Get in Rails Container
bin/open psql Get in PgSQL Container
bin/open redis Get in Redis Container
bin/open elastic Get in ElasticSearch Container
bin/status To see running containers and launched services
bin/start Start everything if it is stopped
bin/stop Stop processes in Rails container
bin/stop_all Stop everything if it is running
bin/cache Toggle caching in development and restart web server
bin/index Run Search engines indexation
bin/reset Reset data od services in ./db folder

Conventions and Agreements

For demonstration, education and maintenance purposes I use the following approach:

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

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

How to Run Tests

From the root of the project

  bin/open rails

Now you are in the Rails container and you can do everything as usual

  RAILS_ENV=test rake db:create
  rake test

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

  • Action Cable Link
  • Nginx

License

MIT

About

Rails7 StartKit. Launch App in minutes!


Languages

Language:Ruby 62.4%Language:HTML 20.1%Language:CSS 6.4%Language:JavaScript 5.9%Language:Dockerfile 5.1%