-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
151 lines (119 loc) · 3.17 KB
/
docker-compose.yml
File metadata and controls
151 lines (119 loc) · 3.17 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
version: '3.8'
services:
context-keeper:
build:
context: .
dockerfile: Dockerfile
args:
VERSION: ${VERSION:-latest}
BUILD_TIME: ${BUILD_TIME}
COMMIT_HASH: ${COMMIT_HASH}
image: context-keeper:${VERSION:-latest}
container_name: context-keeper
restart: unless-stopped
# 环境变量
environment:
- RUN_MODE=${RUN_MODE:-http}
- HTTP_SERVER_PORT=${HTTP_SERVER_PORT:-8088}
- LOG_LEVEL=${LOG_LEVEL:-info}
- STORAGE_PATH=/app/data
- TZ=${TZ:-Asia/Shanghai}
# 端口映射
ports:
- "${HOST_PORT:-8088}:${HTTP_SERVER_PORT:-8088}"
# 卷挂载
volumes:
- ./data:/app/data
- ./logs:/app/logs
- ./config:/app/config
# 健康检查
healthcheck:
test: |
if [ "$RUN_MODE" = "http" ]; then
curl -f http://localhost:${HTTP_SERVER_PORT:-8088}/health || exit 1
else
pgrep -f context-keeper || exit 1
fi
interval: 30s
timeout: 10s
retries: 3
start_period: 30s
# 资源限制
deploy:
resources:
limits:
memory: 512M
cpus: '0.5'
reservations:
memory: 256M
cpus: '0.25'
# 网络配置
networks:
- context-keeper-network
# 日志配置
logging:
driver: "json-file"
options:
max-size: "100m"
max-file: "3"
# 可选:Nginx 反向代理
nginx:
image: nginx:alpine
container_name: context-keeper-nginx
restart: unless-stopped
ports:
- "${NGINX_PORT:-80}:80"
- "${NGINX_SSL_PORT:-443}:443"
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- ./nginx/ssl:/etc/nginx/ssl:ro
- ./logs/nginx:/var/log/nginx
depends_on:
- context-keeper
networks:
- context-keeper-network
profiles:
- proxy
# 可选:监控服务
prometheus:
image: prom/prometheus:latest
container_name: context-keeper-prometheus
restart: unless-stopped
ports:
- "${PROMETHEUS_PORT:-9090}:9090"
volumes:
- ./monitoring/prometheus.yml:/etc/prometheus/prometheus.yml:ro
- prometheus_data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/etc/prometheus/console_libraries'
- '--web.console.templates=/etc/prometheus/consoles'
- '--web.enable-lifecycle'
networks:
- context-keeper-network
profiles:
- monitoring
grafana:
image: grafana/grafana:latest
container_name: context-keeper-grafana
restart: unless-stopped
ports:
- "${GRAFANA_PORT:-3000}:3000"
environment:
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD:-admin}
volumes:
- grafana_data:/var/lib/grafana
- ./monitoring/grafana:/etc/grafana/provisioning
depends_on:
- prometheus
networks:
- context-keeper-network
profiles:
- monitoring
networks:
context-keeper-network:
driver: bridge
volumes:
prometheus_data:
grafana_data: