https://github.com/the-teacher/rails7-startkit
Launch Rails with 1 shell command!
https://github.com/the-teacher/rails7-startkit
docker docker-compose elasticsearch pgsql rails redis ruby sanitize sanitizer sidekiq sphinx whenever
Last synced: about 1 year ago
JSON representation
Launch Rails with 1 shell command!
- Host: GitHub
- URL: https://github.com/the-teacher/rails7-startkit
- Owner: the-teacher
- License: mit
- Created: 2023-01-05T21:33:17.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-09-19T12:13:02.000Z (over 1 year ago)
- Last Synced: 2025-03-31T13:15:28.917Z (about 1 year ago)
- Topics: docker, docker-compose, elasticsearch, pgsql, rails, redis, ruby, sanitize, sanitizer, sidekiq, sphinx, whenever
- Language: Ruby
- Homepage: https://github.com/the-teacher/rails7-startkit
- Size: 12.2 MB
- Stars: 579
- Watchers: 22
- Forks: 79
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Rails 7. Start Kit

Install and Run Ruby on Rails in Minutes!
Copy & Paste in your terminal
❤️ **Linux / MacOS**
```sh
git clone https://github.com/the-teacher/rails7-startkit.git && \
cd rails7-startkit && \
ruby bin/setup
```
💙 **Windows**
```sh
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

## What Is Under the Hood?
Logotype
Description
Why it was added
Main
Docker
Helps to keep all required services in containers. To have fast and predictable installation process in minutes. Docker Images are here.
Ruby 3.2
Most recent version of Ruby
Rails 7
Most recent version of Rails
PostgresSQL
Most popular relational database
Cache and Delayed Jobs
Redis
In-memory data store. For caching and as a dependency of Sidekiq
Sidekiq
Job Scheduler and Async Tasks Executor. Can be used as a stand alone tool or as ActiveJob backend
whenever
Linux Cron based periodical tasks
Full Text Search
Elasticsearch
The world’s leading Search engine
Chewy
Ruby Connector to Elasticsearch
Front-end
Bootstrap
Old but Gold Framework for Web
ES Build
An extremely fast bundler for the web
Import Maps
Rails' recommended way to process JavaScript
Sprockets
Rack-based asset packager
Application Configuration
gem "dotenv"
ENV variables management tool
gem "config"
Configuration management tool
Application Level
Nginx
Web Server. Reverse Proxy. Load Balancer. Caching, Streaming etc.
Puma
Application Web Server. To launch Rails app
Devise
Authentication solution for Rails + Emails confirmations
ActiveStorage
Default Cloud Storage Solution for Rails
Faker
Fake data for development and testing
Kaminari
Pagination solution
Sanitize
Sanitization of a dangerous users' input
mailcatcher
Email previewer for development
Code Quality
RSpec
Testing Framework for Rails
Rubocop
Ruby static code analyzer (a.k.a. linter) and formatter.
Breakman
Static analysis tool | Security Vulnerabilities.
SimpleCov
Code coverage for Ruby (and Rails)
What I'm going to add...
Logotype
Description
Why it was added
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**
```sh
git clone https://github.com/the-teacher/rails7-startkit.git && \
cd rails7-startkit && \
ruby bin/setup
```
💙 **Windows**
```sh
git clone https://github.com/the-teacher/rails7-startkit.git & cd rails7-startkit & ruby bin/setup
```
You will see something like that:
```js
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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](https://guides.rubyonrails.org/action_cable_overview.html)
## Sponsorship
These amazing companies and teams support the project:
JetBrains.com
Hoodies.team
# License
[MIT License. 2023. Ilya N. Zykin](./LICENSE.md)