diff --git a/.env.dev.example b/.env.dev.example index 22e12de12..b65c1b023 100644 --- a/.env.dev.example +++ b/.env.dev.example @@ -26,15 +26,15 @@ POSTGRES_HOST=db MAX_STREAM_LENGTH=200 REDIS_ACTIVITY_HOST=redis_activity REDIS_ACTIVITY_PORT=6379 -#REDIS_ACTIVITY_PASSWORD=redispassword345 +REDIS_ACTIVITY_PASSWORD=redispassword345 # Redis as celery broker REDIS_BROKER_PORT=6379 -#REDIS_BROKER_PASSWORD=redispassword123 +REDIS_BROKER_PASSWORD=redispassword123 FLOWER_PORT=8888 -#FLOWER_USER=mouse -#FLOWER_PASSWORD=changeme +FLOWER_USER=mouse +FLOWER_PASSWORD=changeme EMAIL_HOST=smtp.mailgun.org EMAIL_PORT=587 diff --git a/bookwyrm/redis_store.py b/bookwyrm/redis_store.py index 78f373a2e..3aec8bd68 100644 --- a/bookwyrm/redis_store.py +++ b/bookwyrm/redis_store.py @@ -5,10 +5,12 @@ import redis from bookwyrm import settings r = redis.Redis( - host=settings.REDIS_ACTIVITY_HOST, port=settings.REDIS_ACTIVITY_PORT, db=0 + host=settings.REDIS_ACTIVITY_HOST, + port=settings.REDIS_ACTIVITY_PORT, + password=settings.REDIS_ACTIVITY_PASSWORD, + db=0, ) - class RedisStore(ABC): """sets of ranked, related objects, like statuses for a user's feed""" diff --git a/celerywyrm/settings.py b/celerywyrm/settings.py index 05ffdcabf..082bb5db1 100644 --- a/celerywyrm/settings.py +++ b/celerywyrm/settings.py @@ -3,12 +3,13 @@ # pylint: disable=unused-wildcard-import from bookwyrm.settings import * -CELERY_BROKER_URL = "redis://:{}@redis_broker:{}/0".format( - requests.utils.quote(env("REDIS_BROKER_PASSWORD", "")), env("REDIS_BROKER_PORT") -) -CELERY_RESULT_BACKEND = "redis://:{}@redis_broker:{}/0".format( - requests.utils.quote(env("REDIS_BROKER_PASSWORD", "")), env("REDIS_BROKER_PORT") -) +REDIS_BROKER_PASSWORD = requests.utils.quote(env("REDIS_BROKER_PASSWORD", None)) +REDIS_BROKER_HOST = env("REDIS_BROKER_HOST", "redis_broker") +REDIS_BROKER_PORT = env("REDIS_BROKER_PORT", 6379) + +# pylint: disable=line-too-long +CELERY_BROKER_URL = f"redis://:{REDIS_BROKER_PASSWORD}@{REDIS_BROKER_HOST}:{REDIS_BROKER_PORT}/0" +CELERY_RESULT_BACKEND = f"redis://:{REDIS_BROKER_PASSWORD}@{REDIS_BROKER_HOST}:{REDIS_BROKER_PORT}/0" CELERY_DEFAULT_QUEUE = "low_priority" diff --git a/docker-compose.yml b/docker-compose.yml index afa40b05e..25a397eae 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -38,16 +38,17 @@ services: - 8000:8000 redis_activity: image: redis - command: ["redis-server", "--appendonly", "yes"] + command: redis-server --requirepass ${REDIS_ACTIVITY_PASSWORD} --appendonly yes --port ${REDIS_ACTIVITY_PORT} env_file: .env networks: - main restart: on-failure volumes: + - ./redis.conf:/etc/redis/redis.conf - redis_activity_data:/data redis_broker: image: redis - command: ["redis-server", "--appendonly", "yes"] + command: redis-server --requirepass ${REDIS_BROKER_PASSWORD} --appendonly yes --port ${REDIS_BROKER_PORT} env_file: .env ports: - 6379:6379 @@ -55,6 +56,7 @@ services: - main restart: on-failure volumes: + - ./redis.conf:/etc/redis/redis.conf - redis_broker_data:/data celery_worker: env_file: .env diff --git a/redis.conf b/redis.conf new file mode 100644 index 000000000..2a417579f --- /dev/null +++ b/redis.conf @@ -0,0 +1,9 @@ +bind 127.0.0.1 ::1 +protected-mode yes +port 6379 + +rename-command FLUSHDB "" +rename-command FLUSHALL "" +rename-command DEBUG "" +rename-command CONFIG "" +rename-command SHUTDOWN ""