Skip to content

Commit

Permalink
chore: docker compose databases (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
kadru committed May 28, 2023
1 parent c1eeb7c commit 1f0b5f0
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 15 deletions.
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,7 @@ coverage
/spec/examples.txt

.env
.env.test
.env.development
.env.*
.compose.env
.postgres.env

40 changes: 27 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,38 @@
# README
# Waterflow

This README would normally document whatever steps are necessary to get the
application up and running.
## Requirements

Things you may want to cover:
- ruby 3.1.x
- node 14.x
- redis 6.x
- postgresql 11
- Docker ~> 24
- Docker compose ~> 1.29

* Ruby version
## Setup project environment variables

* System dependencies
1. Copy `env.development.example` to `env.development.local` and `.env.test.example` to `.env.test.local`

* Configuration
```bash
cp env.development.examplet .env.development.local && cp env.test.example .env.test.local
```

* Database creation
2. Change the values for appropiate ones.

* Database initialization
## Setup database

* How to run the test suite
### With docker-compose

* Services (job queues, cache servers, search engines, etc.)
1. Copy `compose.example` and `.postgres.env` to `.compose.env` and `.postgres.env`.

* Deployment instructions
```bash
cp compose.example .compose.env && cp postgres.example .postgres.env
```

* ...
2. Change the values of the variables for appropiate ones. For example choose a more secure password for postgres and choose and port that make no conflict with local setup

3. Start the containers

```bash
sudo docker-compose --env-file .compose.env up
```
3 changes: 3 additions & 0 deletions compose.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Choose a port that makes no conflicts with your local setup
POSTGRES_PORT=6432
SIDEKIQ_REDIS_PORT=7379
21 changes: 21 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
services:
postgres:
image: postgres:11
restart: unless-stopped
ports:
- ${POSTGRES_PORT}:5432
env_file:
- .postgres.env
volumes:
- postgres_data:/var/lib/postgresql/data
sidekiq_redis:
image: redis:6.2
restart: unless-stopped
ports:
- ${SIDEKIQ_REDIS_PORT}:6379
volumes:
- sidekiq_redis_data:/data

volumes:
postgres_data:
sidekiq_redis_data:
3 changes: 3 additions & 0 deletions env.development.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DATABASE_URL=postgres://user:password@Hhost:port/database
REDIS_PROVIDER=redis://host:port
MAPBOX_TOKEN=example_token
3 changes: 3 additions & 0 deletions env.test.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DATABASE_URL=postgres://user:password@Hhost:port/database
# optional
# REDIS_PROVIDER=redis://host:port
2 changes: 2 additions & 0 deletions postgres.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Choose a more secure password
POSTGRES_PASSWORD=postgres

0 comments on commit 1f0b5f0

Please sign in to comment.