优化 docker-compose.yml 中 Redis 依赖服务的安全性和隔离性
去除 Redis 服务的 ports 配置,只允许 Docker Compose 启动的服务才可以访问Redis,不会暴露到宿主机上也不会和宿主机产生端口冲突;同时也提升安全性。
This commit is contained in:
parent
c6717307d0
commit
867338c55a
@ -13,11 +13,13 @@ services:
|
|||||||
- ./logs:/app/logs
|
- ./logs:/app/logs
|
||||||
environment:
|
environment:
|
||||||
- SQL_DSN=root:123456@tcp(host.docker.internal:3306)/one-api # 修改此行,或注释掉以使用 SQLite 作为数据库
|
- SQL_DSN=root:123456@tcp(host.docker.internal:3306)/one-api # 修改此行,或注释掉以使用 SQLite 作为数据库
|
||||||
- REDIS_CONN_STRING=redis://redis:6379
|
- REDIS_CONN_STRING=redis://redis
|
||||||
- SESSION_SECRET=random_string # 修改为随机字符串
|
- SESSION_SECRET=random_string # 修改为随机字符串
|
||||||
- TZ=Asia/Shanghai
|
- TZ=Asia/Shanghai
|
||||||
# - SYNC_FREQUENCY=60 # 多机部署时从节点取消注释该行
|
# - SYNC_FREQUENCY=60 # 多机部署时从节点取消注释该行
|
||||||
# - FRONTEND_BASE_URL=https://openai.justsong.cn # 多机部署时从节点取消注释该行
|
# - FRONTEND_BASE_URL=https://openai.justsong.cn # 多机部署时从节点取消注释该行
|
||||||
|
depends_on:
|
||||||
|
- redis
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: [ "CMD-SHELL", "curl -s http://localhost:3000/api/status | grep -o '\"success\":\\s*true' | awk '{print $2}' | grep 'true'" ]
|
test: [ "CMD-SHELL", "curl -s http://localhost:3000/api/status | grep -o '\"success\":\\s*true' | awk '{print $2}' | grep 'true'" ]
|
||||||
interval: 30s
|
interval: 30s
|
||||||
@ -28,5 +30,3 @@ services:
|
|||||||
image: redis:latest
|
image: redis:latest
|
||||||
container_name: redis
|
container_name: redis
|
||||||
restart: always
|
restart: always
|
||||||
ports:
|
|
||||||
- "6379:6379"
|
|
||||||
|
Loading…
Reference in New Issue
Block a user