Skip to content

Commit 6c6ed34

Browse files
authored
Merge pull request #62 from YuriiMotov/compose_config_edit
Some corrections and improvements to run with docker compose
2 parents 67eb9fc + cc78ea9 commit 6c6ed34

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

README.md

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,8 @@ git clone https://github.com/igormagalhaesr/FastAPI-boilerplate
117117
```
118118

119119
### 3.1 Environment Variables (.env)
120-
And create a ".env" file:
121120

122-
Then create a `.env` file:
121+
Then create a `.env` file inside `src` directory:
123122
```sh
124123
touch .env
125124
```
@@ -140,8 +139,8 @@ For the database ([`if you don't have a database yet, click here`]()), create:
140139
# ------------- database -------------
141140
POSTGRES_USER="your_postgres_user"
142141
POSTGRES_PASSWORD="your_password"
143-
POSTGRES_SERVER="your_server" # default localhost
144-
POSTGRES_PORT=5432
142+
POSTGRES_SERVER="your_server" # default "localhost", if using docker compose you should use "db"
143+
POSTGRES_PORT=5432 # default "5432", if using docker compose you should use "5432"
145144
POSTGRES_DB="your_db"
146145
```
147146

@@ -170,23 +169,22 @@ ADMIN_PASSWORD="your_password"
170169

171170
For redis caching:
172171
```
173-
# ------------- redis -------------
174-
REDIS_CACHE_HOST="your_host" # default "localhost", if using docker compose you should user "redis"
175-
REDIS_CACHE_PORT=6379
172+
# ------------- redis cache-------------
173+
REDIS_CACHE_HOST="your_host" # default "localhost", if using docker compose you should use "redis"
174+
REDIS_CACHE_PORT=6379 # default "6379", if using docker compose you should use "6379"
176175
```
177176

178177
And for client-side caching:
179178
```
180-
# ------------- redis cache -------------
181-
REDIS_CACHE_HOST="your_host" # default "localhost", if using docker compose you should user "redis"
182-
REDIS_CACHE_PORT=6379
179+
# ------------- redis client-side cache -------------
180+
CLIENT_CACHE_MAX_AGE=30 # default "30"
183181
```
184182

185183
For ARQ Job Queues:
186184
```
187185
# ------------- redis queue -------------
188-
REDIS_CACHE_HOST="your_host" # default "localhost", if using docker compose you should use "db"
189-
REDIS_CACHE_PORT=6379
186+
REDIS_QUEUE_HOST="your_host" # default "localhost", if using docker compose you should use "redis"
187+
REDIS_QUEUE_PORT=6379 # default "6379", if using docker compose you should use "6379"
190188
```
191189
> [!WARNING]
192190
> You may use the same redis for both caching and queue while developing, but the recommendation is using two separate containers for production.
@@ -200,8 +198,8 @@ TIER_NAME="free"
200198
For the rate limiter:
201199
```
202200
# ------------- redis rate limit -------------
203-
REDIS_RATE_LIMIT_HOST="localhost" # default="localhost"
204-
REDIS_RATE_LIMIT_PORT=6379 # default=6379
201+
REDIS_RATE_LIMIT_HOST="localhost" # default="localhost", if using docker compose you should use "redis"
202+
REDIS_RATE_LIMIT_PORT=6379 # default=6379, if using docker compose you should use "6379"
205203
206204
207205
# ------------- default rate limit settings -------------

docker-compose.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ services:
1010
# command: gunicorn app.main:app -w 4 -k uvicorn.workers.UvicornWorker -b 0.0.0.0:8000
1111
env_file:
1212
- ./src/.env
13+
# -------- replace with comment if you are using nginx --------
1314
ports:
1415
- "8000:8000"
16+
# expose:
17+
# - "8000"
1518
depends_on:
1619
- db
1720
- redis
@@ -37,13 +40,15 @@ services:
3740
- ./src/.env
3841
volumes:
3942
- postgres-data:/var/lib/postgresql/data
40-
ports:
41-
- "5432:5432"
43+
expose:
44+
- "5432"
4245

4346
redis:
4447
image: redis:alpine
4548
volumes:
4649
- redis-data:/data
50+
expose:
51+
- "6379"
4752

4853
# #-------- uncomment to run with nginx --------
4954
# nginx:

0 commit comments

Comments
 (0)