fix(deploy): make the redis command flags take effect in dev and local compose

PR #4506 fixed this in deploy/docker-compose.yml, but the same broken
form is still in docker-compose.dev.yml and docker-compose.local.yml.
The redis command is one quoted script given to the inner sh -c, and
compose keeps the newlines inside the quoted string, so redis-server on
the first line runs as a complete command with no flags at all. The
--save / --appendonly / --appendfsync lines are silently never applied,
and ${REDIS_PASSWORD:+--requirepass ...} is dead too — redis takes no
password even when REDIS_PASSWORD is set.

The fix is the same trailing `\` line continuations as #4506, with the
same comment, so the three compose files read the same way.

Checked with both files on redis:8-alpine, REDIS_PASSWORD set. Before:
PING with no auth said PONG, appendonly was "no", save was the stock
"3600 1 300 100 60 10000". After: no-auth PING gets NOAUTH, appendonly
is "yes", save is "60 1". With REDIS_PASSWORD unset the server still
starts open, as before.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Nick
2026-07-19 12:16:27 +07:00
co-authored by Claude Fable 5
parent d4b9797ff7
commit 8a2d7c5bd3
2 changed files with 16 additions and 8 deletions
+8 -4
View File
@@ -114,12 +114,16 @@ services:
restart: unless-stopped
volumes:
- ./redis_data:/data:Z
# The command is one quoted script for the inner `sh -c`. Compose keeps
# the newlines inside the quoted string, so every line needs a trailing
# `\` — without it, `redis-server` on the first line runs with no flags
# at all, and the --save/--appendonly/--appendfsync lines are never read.
command: >
sh -c '
redis-server
--save 60 1
--appendonly yes
--appendfsync everysec
redis-server \
--save 60 1 \
--appendonly yes \
--appendfsync everysec \
${REDIS_PASSWORD:+--requirepass "$REDIS_PASSWORD"}'
environment:
- TZ=${TZ:-Asia/Shanghai}
+8 -4
View File
@@ -230,12 +230,16 @@ services:
volumes:
# Local directory mapping for easy migration
- ./redis_data:/data:Z
# The command is one quoted script for the inner `sh -c`. Compose keeps
# the newlines inside the quoted string, so every line needs a trailing
# `\` — without it, `redis-server` on the first line runs with no flags
# at all, and the --save/--appendonly/--appendfsync lines are never read.
command: >
sh -c '
redis-server
--save 60 1
--appendonly yes
--appendfsync everysec
redis-server \
--save 60 1 \
--appendonly yes \
--appendfsync everysec \
${REDIS_PASSWORD:+--requirepass "$REDIS_PASSWORD"}'
environment:
- TZ=${TZ:-Asia/Shanghai}