rails7-startkit
rails7-startkit copied to clipboard
Launch Rails with 1 shell command!
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 | Helps to keep all required services in containers. To have fast and predictable installation process in minutes |
![]() |
PostgresSQL | Most popular relation database |
![]() |
Ruby 3.2 | Most recent version of Ruby |
![]() |
Rails 7 | Most recent version of Rails |
![]() |
gem "config" | Configuration management tool |
![]() |
Elasticsearch | The world’s leading Search engine |
![]() |
Chewy | Ruby Connector to Elasticsearch |
![]() |
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 |
![]() |
Import Maps | Rails' recommended way to process JavaScript |
![]() |
Puma | Application Web Server. To launch Rails app |
What I'm going to add...
Logotype | Description | Why it was added |
---|---|---|
![]() |
Kaminari | Pagination solution |
![]() |
Devise | Authentication solution for Rails |
![]() |
Devise | Login with Facebook and Google |
![]() |
Devise and Action Mailer | Sending emails for account confirmations |
![]() |
Letter Opener | Email previwer for development |
![]() |
whenever | Linux Cron based periodical tasks |
![]() |
RSpec | Testing Framework for Rails |
![]() |
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 Rails container
3. Installing Gems. Please Wait
4. Create DB. Migrate DB. Create Seeds
5. Launching Redis Container
8. Indexing Article Model
9. Launching Rails App with Puma
10. Launching Sidekiq
11. Visit: http://localhost:3000
Index Page of the Project

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/index | Run Search engines indexation |
bin/reset | Reset data od services in ./db folder |
Conventions and Agreements
For demonstration, education and maintainance 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
andUPPERCASED
./config
├── _CONFIG.yml
├── _PUMA.rb
├── _SIDEKIQ.yml
└── _THINKING_SPHINX.yml
Initialazers
- All services' initializers are placed in
./config/initializers
- All files are
_UNDERSCORED
andUPPERCASED
./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 userlucky (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
-
ElasticSearch. Chewy -
Memcached LinkRejected -
Puma on systemd LinkRejected -
Sidekiq on systemd LinkRejected - Action Cable Link
- Nginx
License
MIT