A pretty simplified Docker Compose workflow that sets up (Ruby, Redis, PostgreSQL) network of containers for local ruby development.
Ports used in the project:
| Software | Port |
|---|---|
| ruby | 3000 |
| postgre | 5432 |
| redis | 6379 |
To get started, make sure you have Docker installed on your system and Docker Compose, and then clone this repository.
-
Clone this project:
git clone https://github.com/supermavster/docker-ruby-on-rails.git
-
Inside the folder
docker-rubyand Generate your own.envto docker compose with the next command:cp .env.example .env
-
You need Create or Put your laravel project in the folder source; to create follow the next instructions Here.
-
Build the project whit the next commands:
docker-compose up --build
The configuration of the database must be the same on both sides .
# .env
# Develop Mode
RAILS_ENV=development
# Postgres
POSTGRES_HOST_AUTH_METHOD=trust
# Database Env
DATABASE_NAME=rails_development
DATABASE_USER=supermavster
DATABASE_PASSWORD=password
DATABASE_HOST=database
# Redis data
REDIS_HOST=redis# source/.env
# Develop Mode
RAILS_ENV=development
# Postgres
POSTGRES_HOST_AUTH_METHOD=trust
# Database Env
DATABASE_NAME=rails_development
DATABASE_USER=supermavster
DATABASE_PASSWORD=password
DATABASE_HOST=database
# Redis data
REDIS_HOST=redisThe only change is the DB_HOST in the source/.env where is called to the container of database:
# source/.env
DB_HOST=databasePlease check the file database.yml with the next values:
default: &default
adapter: postgresql
encoding: unicode
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
host: database
username: postgres
password:
development:
<<: *default
adapter: postgresql
encoding: unicode
database: rails_development
username: postgres
password: password
pool: 5
host: database
To Down and remove the volumes we use the next command:
docker-compose down -v