-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-compose.example.yml
More file actions
127 lines (108 loc) · 3.07 KB
/
docker-compose.example.yml
File metadata and controls
127 lines (108 loc) · 3.07 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
# Docker Compose 配置文件示例
# 用于本地开发和生产部署
#
# 使用方法:
# 1. 复制此文件为 docker-compose.yml
# 2. 根据需要修改配置
# 3. 运行: docker-compose up -d
version: '3.8'
services:
# ========================================
# DailyHotApi 服务 (不含 Redis)
# ========================================
api:
# 本地镜像方式(开发时使用)
# build: .
# Docker Hub 镜像方式(生产时使用,替换 your_username)
image: dailyhot-api-go:latest
# image: your_username/dailyhot-api-go:1.0.0
container_name: dailyhot-api
# 端口映射: 宿主机端口:容器端口
ports:
- "6688:6688"
# 环境变量
environment:
# 服务器配置
- DAILYHOT_SERVER_PORT=6688
- DAILYHOT_SERVER_HOST=0.0.0.0
- DAILYHOT_SERVER_READ_TIMEOUT=10s
- DAILYHOT_SERVER_WRITE_TIMEOUT=10s
# 缓存配置(L1:内存缓存)
- DAILYHOT_CACHE_ENABLED=true
- DAILYHOT_CACHE_DEFAULT_EXPIRE=5m
- DAILYHOT_CACHE_CLEANUP_INTERVAL=10m
- DAILYHOT_CACHE_MAX_ENTRIES=10000
- DAILYHOT_CACHE_HARD_MAX_CACHE_SIZE=256
# Redis 配置(L2:分布式缓存,默认禁用)
- DAILYHOT_REDIS_ENABLED=false
# 如果启用 Redis,取消注释以下行:
# - DAILYHOT_REDIS_ENABLED=true
# - DAILYHOT_REDIS_HOST=redis
# - DAILYHOT_REDIS_PORT=6379
# - DAILYHOT_REDIS_PASSWORD=
# - DAILYHOT_REDIS_DB=0
# 日志配置
- DAILYHOT_LOG_LEVEL=info
- DAILYHOT_LOG_FORMAT=console
- DAILYHOT_LOG_OUTPUT_PATH=/app/logs/app.log
- TZ=Asia/Shanghai
# 数据卷挂载
volumes:
# 配置文件(可选)
# - ./config.yaml:/app/config.yaml:ro
# 日志目录
- ./logs:/app/logs
# 自动重启策略
restart: unless-stopped
# 健康检查
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:6688/health"]
interval: 30s
timeout: 3s
retries: 3
start_period: 10s
# 网络
networks:
- dailyhot-network
# 依赖关系(可选,如果启用 Redis)
# depends_on:
# redis:
# condition: service_healthy
# ========================================
# Redis 服务 (可选)
# ========================================
# 取消注释以下代码来启用 Redis
# redis:
# image: redis:7-alpine
# container_name: dailyhot-redis
#
# ports:
# - "6379:6379"
#
# command: redis-server --appendonly yes
#
# volumes:
# - redis-data:/data
#
# restart: unless-stopped
#
# healthcheck:
# test: ["CMD", "redis-cli", "ping"]
# interval: 30s
# timeout: 3s
# retries: 3
#
# networks:
# - dailyhot-network
# ========================================
# 数据卷定义
# ========================================
volumes:
# redis-data:
# driver: local
# ========================================
# 网络定义
# ========================================
networks:
dailyhot-network:
driver: bridge