Skip to content

Commit

Permalink
refactor: use redis in local docker-compose environment
Browse files Browse the repository at this point in the history
  • Loading branch information
infinitewarp committed Jun 24, 2024
1 parent 010aea4 commit 3871aa9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
11 changes: 10 additions & 1 deletion config/settings/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,16 @@
# https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
SECRET_KEY = env("DJANGO_SECRET_KEY", default="local")

CACHES = {"default": {"BACKEND": "django.core.cache.backends.locmem.LocMemCache"}}
REDIS_URL = env("REDIS_URL")
if REDIS_URL:
CACHES = {
"default": {
"BACKEND": "django.core.cache.backends.redis.RedisCache",
"LOCATION": REDIS_URL,
}
}
else:
CACHES = {"default": {"BACKEND": "django.core.cache.backends.locmem.LocMemCache"}}

# https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
INSTALLED_APPS += ("django_extensions",)
Expand Down
9 changes: 9 additions & 0 deletions dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,22 @@ services:
ports:
- "5432:5432"

redis:
image: redis:alpine
restart: always
expose:
- 6379
ports:
- '6379:6379'

django:
build:
context: .
dockerfile: ./compose/django/Dockerfile-dev
command: /start-dev.sh
depends_on:
- postgres
- redis
environment:
- POSTGRES_USER=quips
- POSTGRES_PASSWORD=quips
Expand Down

0 comments on commit 3871aa9

Please sign in to comment.