feat: add redis

This commit is contained in:
Sun-ZhenXing
2025-09-21 16:40:26 +08:00
parent e04f439c3b
commit 92fd82cbb3
7 changed files with 179 additions and 0 deletions

11
src/redis/.env.example Normal file
View File

@@ -0,0 +1,11 @@
# App version
REDIS_VERSION="8.2.1-alpine3.22"
# Skip fixing permissions, set to 1 to skip
SKIP_FIX_PERMS=1
# Password for the default "default" user
REDIS_PASSWORD="passw0rd"
# Port to bind to on the host machine
REDIS_PORT_OVERRIDE_6379=16379

12
src/redis/README.md Normal file
View File

@@ -0,0 +1,12 @@
# Redis
## Environment Variables
| Variable Name | Description | Default Value |
| ------------------------ | -------------------------------------------------------- | -------------------- |
| REDIS_VERSION | Redis image version | `"8.2.1-alpine3.22"` |
| SKIP_FIX_PERMS | Skip permission fixing, set to 1 to skip | `""` |
| REDIS_PASSWORD | Password for the default "default" user | `""` |
| REDIS_PORT_OVERRIDE_6379 | Host port mapping (maps to Redis port 6379 in container) | 6379 |
Please modify the `.env` file as needed for your use case.

View File

@@ -0,0 +1,41 @@
x-default: &default
restart: unless-stopped
volumes:
- &localtime /etc/localtime:/etc/localtime:ro
- &timezone /etc/timezone:/etc/timezone:ro
logging:
driver: json-file
options:
max-size: 100m
services:
redis:
<<: *default
image: redis:${REDIS_VERSION:-8.2.1-alpine3.22}
container_name: redis
ports:
- "${REDIS_PORT_OVERRIDE_6379:-6379}:6379"
volumes:
- *localtime
- *timezone
- redis_data:/data
# !! Uncomment to use a custom redis.conf file
# - ./redis.conf:/etc/redis/redis.conf
environment:
- SKIP_FIX_PERMS=${SKIP_FIX_PERMS:-}
command:
- redis-server
- --requirepass
- ${REDIS_PASSWORD:-}
deploy:
resources:
limits:
cpus: '0.50'
memory: 512M
reservations:
cpus: '0.25'
memory: 256M
volumes:
redis_data: