Skip to content

Commit

Permalink
feat(caching): configs and containers
Browse files Browse the repository at this point in the history
  • Loading branch information
mohamad-liyaghi committed Jul 31, 2024
1 parent 37221f4 commit b664596
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 0 deletions.
10 changes: 10 additions & 0 deletions config/settings/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,13 @@
},
},
}

CACHES = {
"default": {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": config("CACHE_DB_URL"),
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
},
}
}
13 changes: 13 additions & 0 deletions docker-compose.base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ services:
interval: 2s
timeout: 5s
retries: 5
redis:
restart: on-failure
container_name: food-anywhere-redis
image: redis:6.2-alpine
expose:
- "6379"
networks:
- main
healthcheck:
test: [ "CMD", "redis-cli", "ping" ]
interval: 2s
timeout: 5s
retries: 5

networks:
main:
4 changes: 4 additions & 0 deletions docker-compose.prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ services:
file: docker-compose.base.yaml
env_file:
- envs/.env.prod
redis:
extends:
service: redis
file: docker-compose.base.yaml

networks:
main:
Expand Down
4 changes: 4 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ services:
file: docker-compose.base.yaml
env_file:
- envs/.env.local
redis:
extends:
service: redis
file: docker-compose.base.yaml

networks:
main:
Expand Down
3 changes: 3 additions & 0 deletions envs/.env.local
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ POSTGRES_PASSWORD=postgres
POSTGRES_DB=food_anywhere_local
POSTGRES_HOST=postgres
POSTGRES_PORT=5432

# Redis
CACHE_DB_URL='redis://redis:6379/2'
3 changes: 3 additions & 0 deletions envs/.env.prod
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ POSTGRES_PASSWORD=postgres
POSTGRES_DB=food_anywhere_prod
POSTGRES_HOST=postgres
POSTGRES_PORT=5432

# Redis
CACHE_DB_URL='redis://redis:6379/2'
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ cfgv==3.4.0
click==8.1.7
distlib==0.3.8
Django==5.0.7
django-redis==5.4.0
filelock==3.15.4
identify==2.6.0
iniconfig==2.0.0
Expand All @@ -20,5 +21,6 @@ pytest-django==4.8.0
pytest-env==1.1.3
python-decouple==3.8
PyYAML==6.0.1
redis==5.0.8
sqlparse==0.5.1
virtualenv==20.26.3

0 comments on commit b664596

Please sign in to comment.