Skip to content

Commit

Permalink
fix: redis connection string from params
Browse files Browse the repository at this point in the history
  • Loading branch information
Antti Viitala committed Dec 18, 2023
1 parent 9855588 commit 29e6a42
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
9 changes: 7 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@ services:
DEBUG: "False"
RUN_MIGRATIONS: "True"
DJANGO_SECRET_KEY: "insecure-key-fill-with-your-own"
REDIS_PRIVATE_URL: "redis://redis:6379"
# Postgres params
POSTGRES_HOST: "db"
POSTGRES_PORT: "5432"
POSTGRES_DB: "postgres"
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: "postgres"
POSTGRES_PORT: "5432"
# Redis params
REDISHOST: "redis"
REDISPORT: "6379"
REDISUSER: "default"
REDISPASSWORD: "asd"
depends_on: &app-depends-on
- db
- redis
Expand Down
8 changes: 6 additions & 2 deletions railway_django_stack/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,12 @@
}
}

# "redis://default:[email protected]:34680"
REDIS_URL = f"redis://{config('REDISUSER', default='default')}:{config('REDISPASSWORD', default='')}@{config('REDISHOST', default='redis')}:{config('REDISPORT', default=6379)}"


# CELERY CONFIG
CELERY_BROKER_URL = config("REDIS_URL", default="redis://redis:6379")
CELERY_BROKER_URL = REDIS_URL
CELERY_RESULT_BACKEND = config("CELERY_RESULT_BACKEND", default="django-db")
CELERY_BEAT_SCHEDULER = config(
"CELERY_BEAT_SCHEDULER", default="django_celery_beat.schedulers.DatabaseScheduler"
Expand All @@ -98,7 +102,7 @@
CACHES = {
"default": {
"BACKEND": "django.core.cache.backends.redis.RedisCache",
"LOCATION": config("REDIS_PRIVATE_URL", default="redis://redis:6379"),
"LOCATION": REDIS_URL,
}
}

Expand Down

0 comments on commit 29e6a42

Please sign in to comment.