migration to valkey from redis

This commit is contained in:
Pravin Kamble 2025-10-29 20:34:43 +05:30
parent e168dcad0a
commit 39f7bed452
10 changed files with 29 additions and 31 deletions

View File

@ -76,8 +76,8 @@ jobs:
name: "Bare metal ${{ matrix.script.name }}"
runs-on: ubuntu-latest
services:
redis:
image: redis:7.2
valkey:
image: valkey/valkey:latest
ports:
- 6379:6379
postgres:

View File

@ -51,7 +51,7 @@ docker compose -f docker-compose.local.yml run --rm django python manage.py make
# Make sure the check doesn't raise any warnings
docker compose -f docker-compose.local.yml run --rm \
-e DJANGO_SECRET_KEY="$(openssl rand -base64 64)" \
-e REDIS_URL=redis://redis:6379/0 \
-e REDIS_URL=redis://valkey:6379/0 \
-e DJANGO_AWS_ACCESS_KEY_ID=x \
-e DJANGO_AWS_SECRET_ACCESS_KEY=x \
-e DJANGO_AWS_STORAGE_BUCKET_NAME=x \
@ -70,7 +70,7 @@ docker run --rm \
--env-file .envs/.local/.postgres \
--network my_awesome_project_default \
-e DJANGO_SECRET_KEY="$(openssl rand -base64 64)" \
-e REDIS_URL=redis://redis:6379/0 \
-e REDIS_URL=redis://valkey:6379/0 \
-e DJANGO_AWS_ACCESS_KEY_ID=x \
-e DJANGO_AWS_SECRET_ACCESS_KEY=x \
-e DJANGO_AWS_STORAGE_BUCKET_NAME=x \
@ -83,4 +83,4 @@ django-prod python manage.py check --settings=config.settings.production --deplo
if [ -f "package.json" ]
then
docker compose -f docker-compose.local.yml run --rm node npm run build
fi
fi

View File

@ -7,7 +7,7 @@ environment:
POSTGRES_DB: 'test_{{ cookiecutter.project_slug }}'
POSTGRES_HOST_AUTH_METHOD: trust
{%- if cookiecutter.use_celery == 'y' %}
REDIS_URL: 'redis://redis:6379/0'
REDIS_URL: 'redis://valkey:6379/0'
{%- endif %}
steps:
@ -46,4 +46,4 @@ steps:
volumes:
- name: pre-commit cache
host:
path: /tmp/drone/cache/pre-commit
path: /tmp/drone/cache/pre-commit

View File

@ -6,7 +6,7 @@ IPYTHONDIR=/app/.ipython
{%- if cookiecutter.use_celery == 'y' %}
# Redis
# ------------------------------------------------------------------------------
REDIS_URL=redis://redis:6379/0
REDIS_URL=redis://valkey:6379/0
# Celery
# ------------------------------------------------------------------------------

View File

@ -66,7 +66,7 @@ SENTRY_DSN=
# Redis
# ------------------------------------------------------------------------------
REDIS_URL=redis://redis:6379/0
REDIS_URL=redis://valkey:6379/0
{% if cookiecutter.use_celery == 'y' %}
# Celery
# ------------------------------------------------------------------------------

View File

@ -43,8 +43,8 @@ jobs:
services:
{%- if cookiecutter.use_celery == 'y' %}
redis:
image: redis:7.2
valkey:
image: valkey/valkey:latest
ports:
- 6379:6379
{%- endif %}

View File

@ -8,7 +8,7 @@ variables:
POSTGRES_DB: 'test_{{ cookiecutter.project_slug }}'
POSTGRES_HOST_AUTH_METHOD: trust
{%- if cookiecutter.use_celery == 'y' %}
REDIS_URL: 'redis://redis:6379/0'
REDIS_URL: 'redis://valkey:6379/0'
{%- endif %}
precommit:

View File

@ -285,7 +285,8 @@ LOGGING = {
"root": {"level": "INFO", "handlers": ["console"]},
}
REDIS_URL = env("REDIS_URL", default="redis://{% if cookiecutter.use_docker == 'y' %}redis{%else%}localhost{% endif %}:6379/0")
# Use Valkey service name instead of Redis
REDIS_URL = env("REDIS_URL", default="redis://{% if cookiecutter.use_docker == 'y' %}valkey{%else%}localhost{% endif %}:6379/0")
REDIS_SSL = REDIS_URL.startswith("rediss://")
{% if cookiecutter.use_celery == 'y' -%}

View File

@ -1,7 +1,7 @@
volumes:
{{ cookiecutter.project_slug }}_local_postgres_data: {}
{{ cookiecutter.project_slug }}_local_postgres_data_backups: {}
{% if cookiecutter.use_celery == 'y' %}{{ cookiecutter.project_slug }}_local_redis_data: {}{% endif %}
{% if cookiecutter.use_celery == 'y' %}{{ cookiecutter.project_slug }}_local_valkey_data: {}{% endif %}
services:
django:{% if cookiecutter.use_celery == 'y' %} &django{% endif %}
@ -13,7 +13,7 @@ services:
depends_on:
- postgres
{%- if cookiecutter.use_celery == 'y' %}
- redis
- valkey
{%- endif %}
{%- if cookiecutter.use_mailpit == 'y' %}
- mailpit
@ -51,18 +51,18 @@ services:
{%- endif %}
{%- if cookiecutter.use_celery == 'y' %}
redis:
image: docker.io/redis:7.2
container_name: {{ cookiecutter.project_slug }}_local_redis
valkey:
image: valkey/valkey:latest
container_name: {{ cookiecutter.project_slug }}_local_valkey
volumes:
- {{ cookiecutter.project_slug }}_local_redis_data:/data
- {{ cookiecutter.project_slug }}_local_valkey_data:/data
celeryworker:
<<: *django
image: {{ cookiecutter.project_slug }}_local_celeryworker
container_name: {{ cookiecutter.project_slug }}_local_celeryworker
depends_on:
- redis
- valkey
- postgres
{%- if cookiecutter.use_mailpit == 'y' %}
- mailpit
@ -75,7 +75,7 @@ services:
image: {{ cookiecutter.project_slug }}_local_celerybeat
container_name: {{ cookiecutter.project_slug }}_local_celerybeat
depends_on:
- redis
- valkey
- postgres
{%- if cookiecutter.use_mailpit == 'y' %}
- mailpit
@ -114,4 +114,4 @@ services:
- '3001:3001'
{%- endif %}
{%- endif %}
{%- endif %}

View File

@ -6,10 +6,9 @@ volumes:
production_django_media: {}
{%- endif %}
{% if cookiecutter.use_celery == 'y' %}
production_redis_data: {}
production_valkey_data: {}
{% endif %}
services:
django:{% if cookiecutter.use_celery == 'y' %} &django{% endif %}
build:
@ -17,7 +16,6 @@ services:
dockerfile: ./compose/production/django/Dockerfile
{%- if cookiecutter.frontend_pipeline == 'Webpack' and cookiecutter.use_whitenoise == 'n' %}
args:
# These variable can be defined in an .env file in the root of the repo
{%- if cookiecutter.cloud_provider == 'AWS' %}
DJANGO_AWS_STORAGE_BUCKET_NAME: ${DJANGO_AWS_STORAGE_BUCKET_NAME}
DJANGO_AWS_S3_CUSTOM_DOMAIN: ${DJANGO_AWS_S3_CUSTOM_DOMAIN}
@ -35,7 +33,7 @@ services:
{%- endif %}
depends_on:
- postgres
- redis
- valkey
env_file:
- ./.envs/.production/.django
- ./.envs/.production/.postgres
@ -68,14 +66,13 @@ services:
- '0.0.0.0:5555:5555'
{%- endif %}
redis:
image: docker.io/redis:7.2
valkey:
image: valkey/valkey:latest
{% if cookiecutter.use_celery == 'y' %}
volumes:
- production_redis_data:/data
- production_valkey_data:/data
{% endif %}
{%- if cookiecutter.use_celery == 'y' %}
celeryworker:
@ -115,4 +112,4 @@ services:
- django
volumes:
- production_django_media:/usr/share/nginx/media:ro
{%- endif %}
{%- endif %}