Skip to content

Commit

Permalink
Merge pull request #62 from YuriiMotov/compose_config_edit
Browse files Browse the repository at this point in the history
Some corrections and improvements to run with docker compose
  • Loading branch information
igorbenav committed Nov 29, 2023
2 parents 67eb9fc + cc78ea9 commit 6c6ed34
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
26 changes: 12 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,8 @@ git clone https://github.com/igormagalhaesr/FastAPI-boilerplate
```

### 3.1 Environment Variables (.env)
And create a ".env" file:

Then create a `.env` file:
Then create a `.env` file inside `src` directory:
```sh
touch .env
```
Expand All @@ -140,8 +139,8 @@ For the database ([`if you don't have a database yet, click here`]()), create:
# ------------- database -------------
POSTGRES_USER="your_postgres_user"
POSTGRES_PASSWORD="your_password"
POSTGRES_SERVER="your_server" # default localhost
POSTGRES_PORT=5432
POSTGRES_SERVER="your_server" # default "localhost", if using docker compose you should use "db"
POSTGRES_PORT=5432 # default "5432", if using docker compose you should use "5432"
POSTGRES_DB="your_db"
```

Expand Down Expand Up @@ -170,23 +169,22 @@ ADMIN_PASSWORD="your_password"

For redis caching:
```
# ------------- redis -------------
REDIS_CACHE_HOST="your_host" # default "localhost", if using docker compose you should user "redis"
REDIS_CACHE_PORT=6379
# ------------- redis cache-------------
REDIS_CACHE_HOST="your_host" # default "localhost", if using docker compose you should use "redis"
REDIS_CACHE_PORT=6379 # default "6379", if using docker compose you should use "6379"
```

And for client-side caching:
```
# ------------- redis cache -------------
REDIS_CACHE_HOST="your_host" # default "localhost", if using docker compose you should user "redis"
REDIS_CACHE_PORT=6379
# ------------- redis client-side cache -------------
CLIENT_CACHE_MAX_AGE=30 # default "30"
```

For ARQ Job Queues:
```
# ------------- redis queue -------------
REDIS_CACHE_HOST="your_host" # default "localhost", if using docker compose you should use "db"
REDIS_CACHE_PORT=6379
REDIS_QUEUE_HOST="your_host" # default "localhost", if using docker compose you should use "redis"
REDIS_QUEUE_PORT=6379 # default "6379", if using docker compose you should use "6379"
```
> [!WARNING]
> You may use the same redis for both caching and queue while developing, but the recommendation is using two separate containers for production.
Expand All @@ -200,8 +198,8 @@ TIER_NAME="free"
For the rate limiter:
```
# ------------- redis rate limit -------------
REDIS_RATE_LIMIT_HOST="localhost" # default="localhost"
REDIS_RATE_LIMIT_PORT=6379 # default=6379
REDIS_RATE_LIMIT_HOST="localhost" # default="localhost", if using docker compose you should use "redis"
REDIS_RATE_LIMIT_PORT=6379 # default=6379, if using docker compose you should use "6379"
# ------------- default rate limit settings -------------
Expand Down
9 changes: 7 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ services:
# command: gunicorn app.main:app -w 4 -k uvicorn.workers.UvicornWorker -b 0.0.0.0:8000
env_file:
- ./src/.env
# -------- replace with comment if you are using nginx --------
ports:
- "8000:8000"
# expose:
# - "8000"
depends_on:
- db
- redis
Expand All @@ -37,13 +40,15 @@ services:
- ./src/.env
volumes:
- postgres-data:/var/lib/postgresql/data
ports:
- "5432:5432"
expose:
- "5432"

redis:
image: redis:alpine
volumes:
- redis-data:/data
expose:
- "6379"

# #-------- uncomment to run with nginx --------
# nginx:
Expand Down

0 comments on commit 6c6ed34

Please sign in to comment.