This project is Playground for Rails 7
with using Docker
.
Usually It is difficult and time consuming to setup a typical rails environment from scratch.
With this project you can start development process in minutes.
- Ruby 3.2
- Rails 7
- PgSQL (Database)
- Redis (Cache)
- Sidekiq (Async and Delayed Jobs)
- Sphinx (Full text search)
- Puma (Web Server)
All trademarks, logos and brand names are the property of their respective owners.
On your host you have:
- Ruby 2+
- Docker
- Git
git clone git@github.com:the-teacher/rails7-docker.git
cd rails7-docker
bin/setup
1. Launching PgSQL container
2. Launching Rails container
3. Installing Gems. Please Wait
4. Create DB. Migrate DB. Create Seeds
5. Launching Redis Container
6. Generate Sphinx Config
7. Launching Sphinx Container
8. Indexing Article Model
9. Launching Rails App on the port 3000
10. Visit: http://localhost:3000
From the root of the project
docker compose -f docker/docker-compose.yml up -d
[+] Running 4/4
⠿ Container rails7app-redis-1 Running
⠿ Container rails7app-psql-1 Running
⠿ Container rails7app-sphinx-1 Running
⠿ Container rails7app-rails-1 Running
docker ps --format 'table {{.Names}}\t{{.ID}}\t{{.Image}}\t{{.Ports}}'
NAMES CONTAINER ID IMAGE PORTS
rails7app-sphinx-1 7379414a8127 macbre/sphinxsearch:3.4.1 36307/tcp
rails7app-redis-1 df3cc69795bb redis:7.0.5-alpine 6379/tcp
rails7app-rails-1 2042c1346ef1 iamteacher/rails7:2023.arm64 0.0.0.0:3000->3000/tcp
rails7app-psql-1 60bf07fc70fe postgres:15.1-bullseye 5432/tcp
Rails
docker exec -ti rails7app-rails-1 bash
PgSQL
docker exec -ti rails7app-psql-1 bash
Redis
docker exec -ti rails7app-psql-1 ash
Sphinx
docker exec -ti rails7app-sphinx-1 ash
From the root of the project
docker compose -f docker/docker-compose.yml down
[+] Running 4/4
⠿ Container rails7app-redis-1 Removed
⠿ Container rails7app-psql-1 Removed
⠿ Container rails7app-sphinx-1 Removed
⠿ Container rails7app-rails-1 Removed
For demonstration, education and maintainance purposes I use the following approach:
Data
- All data related folders for services are placed in
./db
- All service related folders are
UPPERCASED
./db
├── PGSQL
├── REDIS
└── SPHINX
Configuration Files
- All services' configurations are placed in
./config
- All service related configs are
_UNDERSCORED
andUPPERCASED
./config
├── _SPHINX (<< folder)
├── _PUMA.rb
├── _SIDEKIQ.yml
└── _THINKING_SPHINX.yml
Initialazers
- All services' initializers are placed in
./config/initializers
- All services' initializers are
_UNDERSCORED
andUPPERCASED
./config/initializers/
├── _REDIS.rb
├── _SIDEKIQ.rb
└── _SPHINX.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
- ElasticSearch. Chewy
Memcached LinkRejected- Puma on systemd Link
- Sidekiq on systemd Link
- Action Cable Link
- Nginx
MIT