the-teacher / rails7-startkit
- четверг, 12 января 2023 г. в 00:37:37
Rails7 StartKit. Launch App in minutes!
Rails 7 App with Preinstalled Tools is Ready in Minutes!
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 I'm going to add...
All trademarks, logos and brand names are the property of their respective owners.
On your host you have:
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
bin/
commandsFrom 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 |
For demonstration, education and maintainance purposes I use the following approach:
Data
./db
UPPERCASED
./db
├── ELASTIC
├── PGSQL
└── REDIS
Configuration Files
./config
_UNDERSCORED
and UPPERCASED
./config
├── _CONFIG.yml
├── _PUMA.rb
├── _SIDEKIQ.yml
└── _THINKING_SPHINX.yml
Initialazers
./config/initializers
_UNDERSCORED
and UPPERCASED
./config/initializers/
├── _CHEWY.rb
├── _CONFIG.rb
├── _REDIS.rb
└── _SIDEKIQ.rb
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:
lucky (7777)
and user lucky (7777)
RUN_AS=7777:7777
optionFrom 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
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.
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?
I use tools that I like or want to learn.
I use tools that I think are the most popular ones.
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.
MIT