From fe61216f95208d419c4824296bb90b1c05711d74 Mon Sep 17 00:00:00 2001 From: Alexey Skobkin Date: Wed, 6 Mar 2024 21:44:58 +0300 Subject: [PATCH] redis. Adding persistence. --- redis/.env.dist | 6 +++++- redis/data/.gitignore | 2 ++ redis/docker-compose.yml | 9 ++++----- 3 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 redis/data/.gitignore diff --git a/redis/.env.dist b/redis/.env.dist index a4a2e70..5a5f99a 100644 --- a/redis/.env.dist +++ b/redis/.env.dist @@ -1,7 +1,11 @@ # https://hub.docker.com/_/redis # Uncomment to use directory binding instead of docker volume (almost always not needed) -#DATA_PATH=/some/path +HOST_DATA_DIR=./data +# https://redis.io/docs/management/persistence/#snapshotting +PERSISTENCE_PERIOD_SEC=60 +PERSISTENCE_MIN_OPS=1 +LOG_LEVEL=warning LOG_MAX_SIZE=5m LOG_MAX_FILE=5 diff --git a/redis/data/.gitignore b/redis/data/.gitignore new file mode 100644 index 0000000..a68d087 --- /dev/null +++ b/redis/data/.gitignore @@ -0,0 +1,2 @@ +/* +!/.gitignore diff --git a/redis/docker-compose.yml b/redis/docker-compose.yml index 646a8ce..22f0bdf 100644 --- a/redis/docker-compose.yml +++ b/redis/docker-compose.yml @@ -1,10 +1,13 @@ -version: '3.7' +version: '3.8' services: redis: # https://hub.docker.com/_/redis image: redis:alpine container_name: redis + command: "redis-server --save ${PERSISTENCE_PERIOD_SEC:-60} ${PERSISTENCE_MIN_OPS:-1} --loglevel ${LOG_LEVEL:-warning}" + volumes: + - "${HOST_DATA_DIR:-./data}:/data" ports: - "127.0.0.1:6379:6379/tcp" env_file: .env @@ -14,7 +17,3 @@ services: options: max-size: "${LOG_MAX_SIZE:-5m}" max-file: "${LOG_MAX_FILE:-5}" - -#volumes: -# redis_data: -# name: redis_data