Rails App in a Docker container with some popular preinstalled tools.
Save hours, days or weeks on setting up a typical Rails app.
- 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
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 | |
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 | ||
Import Maps | Rails' recommended way to process JavaScript | |
Application Level | ||
gem "config" | Configuration management tool | |
Faker | Fake data for development and testing | |
Sanitize | Sanitization of a dangerous users' input | |
Kaminari | Pagination solution | |
mailcatcher | Email previwer for development | |
Puma | Application Web Server. To launch Rails app | |
Code Quality | ||
Rubocop | Ruby static code analyzer (a.k.a. linter) and formatter. | |
RSpec | Testing Framework for Rails |
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 |
All trademarks, logos and brand names are the property of their respective owners.
ONE!
git clone https://github.com/the-teacher/rails7-startkit.git
TWO!
cd rails7-startkit
THREE!
bin/setup
You will see something like that:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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. Installing Gems
8. Create DB. Migrate DB. Create Seeds
9. Indexing Article Model
10. Launching Rails App with Puma
11. Launching Sidekiq
12. Rubocop is Checking
13. RSpec is Checking
14. Visit Rails App: http://localhost:3000
15. Visit Mail Service: http://localhost:1080
16. Visit ElasticSearch: http://localhost:9200
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Welcome to RAILS 7!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From the root of the project
Command | Description |
---|---|
Most important | |
bin/setup | Download images, run containers, initialize data, launch all processes. |
bin/open | Get in Rails Container |
bin/exec [COMMAND] | Execute a command from Rails7StartKit module |
Command | Description |
---|---|
Get in a container | |
bin/open [NAME] |
Get in a Container. [NAME] can be rails ,
psql , redis , elastic , mailcatcher . Default value is rails .
|
Command | Description |
---|---|
bin/exec | |
bin/exec [COMMAND] | Execute a command from Rails7StartKit module |
Start/Stop/Restart | |
bin/exec start | Start processes in rails container |
bin/exec stop | Stop processes in rails container |
bin/exec restart | bin/exec stop + bin/exec start |
bin/exec start_all | Start processes and containers |
bin/exec stop_all | Stop processes and containers |
bin/exec restart_all | bin/exec stop_all + bin/exec start_all |
Helpers | |
bin/exec status | To see running containers and launched services |
bin/exec cache | Toggle caching in development and restart web server |
bin/exec index | Run Search engines indexation |
bin/exec reset | Reset data of services in ./db folder |
On your host you have:
- Ruby 2+
- Docker
- Git
Show details
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
Initialazers
- All services' initializers are placed in
./config/initializers
- All files are
_UNDERSCORED
andUPPERCASED
./config/initializers/
├── _CHEWY.rb
├── _CONFIG.rb
├── _REDIS.rb
└── _SIDEKIQ.rb
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 userlucky (7777)
- run the project with
RUN_AS=7777:7777
option
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.
Show details
- One command install and run
- Nginx
- Production roll up
- Action Cable Link
MIT