-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-compose.sync.yml
More file actions
100 lines (96 loc) · 2.42 KB
/
docker-compose.sync.yml
File metadata and controls
100 lines (96 loc) · 2.42 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# Docker Compose配置 - 代码同步版本(生产环境但支持代码热更新)
services:
fingerbot:
build:
context: .
dockerfile: Dockerfile
container_name: fingerbot-app-sync
restart: unless-stopped
ports:
- "8080:8080"
environment:
- NODE_ENV=production
- LOG_LEVEL=info
- PORT=8080
env_file:
- .env.docker
volumes:
# 代码同步:挂载编译后的代码目录
- ./dist:/app/dist:ro
- ./src:/app/src:ro # 挂载源码目录(只读)
- ./public:/app/public:ro # 挂载静态文件
# 日志文件挂载到宿主机
- ./logs:/app/logs
# 可选:配置文件挂载
- ./docker/config:/app/config:ro
networks:
- fingerbot-network-sync
depends_on:
- redis
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8080/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
deploy:
resources:
limits:
memory: 512M
cpus: '0.5'
reservations:
memory: 256M
cpus: '0.25'
# Redis用于缓存和会话存储
redis:
image: redis:7-alpine
container_name: fingerbot-redis-sync
restart: unless-stopped
ports:
- "6379:6379"
volumes:
- redis-sync-data:/data
- ./docker/redis.conf:/usr/local/etc/redis/redis.conf:ro
command: redis-server /usr/local/etc/redis/redis.conf
networks:
- fingerbot-network-sync
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 30s
timeout: 3s
retries: 5
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
# 日志管理服务
logrotate:
image: alpine:latest
container_name: fingerbot-logrotate-sync
restart: unless-stopped
volumes:
- ./logs:/app/logs
- ./docker/logrotate.conf:/etc/logrotate.d/fingerbot:ro
command: |
sh -c "
apk add --no-cache logrotate
while true; do
logrotate -f /etc/logrotate.d/fingerbot
sleep 86400
done
"
networks:
- fingerbot-network-sync
networks:
fingerbot-network-sync:
driver: bridge
name: fingerbot-network-sync
volumes:
redis-sync-data:
name: fingerbot-redis-data-sync