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.
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 relational database | |
Ruby 3.2 | Most recent version of Ruby | |
Rails 7 | Most recent version of Rails | |
Puma | Application Web Server. To launch Rails app | |
gem "config" | Configuration management tool | |
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 | |
Elasticsearch | The world’s leading Search engine | |
Chewy | Ruby Connector to Elasticsearch | |
Import Maps | Rails' recommended way to process JavaScript | |
Faker | Fake data for development and testing | |
Sanitize | Sanitization of a dangerous users' input | |
Kaminari | Pagination solution |
What I'm going to add...
Logotype | Description | Why it was added |
---|---|---|
Devise | Authentication solution for Rails | |
Devise | Login with Facebook and Google | |
Devise and Action Mailer | Sending emails for account confirmations | |
mailcatcher | 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.
On your host you have:
- Ruby 2+
- Docker
- Git
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
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 |
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
andUPPERCASED
./config
├── _CONFIG.yml
├── _PUMA.rb
└── _SIDEKIQ.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
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
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
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.
- Action Cable Link
- Nginx
MIT