You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
892 B

#!/usr/bin/env sh
set -eu
# Đọc biến môi trường (có default hợp lý)
REDIS_PASSWORD="${REDIS_PASSWORD:?REDIS_PASSWORD is required}"
REDIS_MAXMEMORY="${REDIS_MAXMEMORY:-512mb}"
REDIS_EVICTION_POLICY="${REDIS_EVICTION_POLICY:-allkeys-lru}"
ENABLE_PERSIST="${ENABLE_PERSIST:-NO}"
# Thư mục dữ liệu
mkdir -p /data
CMD="redis-server \
--requirepass '${REDIS_PASSWORD}' \
--maxmemory ${REDIS_MAXMEMORY} \
--maxmemory-policy ${REDIS_EVICTION_POLICY} \
--bind 0.0.0.0 \
--port 6379 \
--loglevel notice \
--dir /data \
--protected-mode yes"
if [ "${ENABLE_PERSIST}" = "YES" ]; then
# Snapshot nhẹ (RDB): 900s nếu >=1 key đổi; 300s nếu >=10 key
CMD="$CMD --save 900 1 --save 300 10 --appendonly no"
else
# Cache thuần: tắt persist để giảm I/O
CMD="$CMD --save '' --appendonly no"
fi
echo "[entrypoint] Starting: $CMD"
exec sh -c "$CMD"