forked from ding113/claude-code-hub
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yaml
More file actions
76 lines (74 loc) · 2.37 KB
/
docker-compose.yaml
File metadata and controls
76 lines (74 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
services:
postgres:
image: postgres:18
container_name: claude-code-hub-db
restart: unless-stopped
# 不对外暴露数据库端口,仅允许容器内部网络访问
# 如需调试,可取消注释下行(仅绑定本机):
# ports:
# - "127.0.0.1:35432:5432"
env_file:
- ./.env
environment:
POSTGRES_USER: ${DB_USER:-postgres}
POSTGRES_PASSWORD: ${DB_PASSWORD:-postgres}
POSTGRES_DB: ${DB_NAME:-claude_code_hub}
# 使用自定义数据目录
PGDATA: /data/pgdata
# 设置时区为上海
TZ: Asia/Shanghai
PGTZ: Asia/Shanghai
volumes:
# 持久化数据库数据到本地 ./data/postgres 目录
# 挂载到 /data 而不是 /var/lib/postgresql/data 避免权限冲突
- ./data/postgres:/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${DB_USER:-postgres} -d ${DB_NAME:-claude_code_hub}"]
interval: 5s
timeout: 5s
retries: 10
start_period: 10s
redis:
image: redis:7-alpine
container_name: claude-code-hub-redis
restart: unless-stopped
volumes:
# 持久化 Redis 数据到本地 ./data/redis 目录
# 使用 AOF 持久化模式,确保数据不丢失
- ./data/redis:/data
command: redis-server --appendonly yes
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 5
start_period: 5s
app:
image: ghcr.io/ding113/claude-code-hub:latest
container_name: claude-code-hub-app
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
env_file:
- ./.env
environment:
NODE_ENV: production
# 容器内使用 Dockerfile 默认端口 3000,对外通过 APP_PORT 暴露(默认 23000)
DSN: postgresql://${DB_USER:-postgres}:${DB_PASSWORD:-postgres}@postgres:5432/${DB_NAME:-claude_code_hub}
REDIS_URL: redis://redis:6379
AUTO_MIGRATE: ${AUTO_MIGRATE:-true}
ENABLE_RATE_LIMIT: ${ENABLE_RATE_LIMIT:-true}
SESSION_TTL: ${SESSION_TTL:-300}
# 设置时区为上海
TZ: Asia/Shanghai
ports:
- "${APP_PORT:-23000}:3000"
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:3000/api/actions/health || exit 1"]
interval: 30s
timeout: 5s
retries: 3
start_period: 30s