-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
146 lines (139 loc) · 3.51 KB
/
docker-compose.yml
File metadata and controls
146 lines (139 loc) · 3.51 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
services:
api:
build:
context: .
dockerfile: Dockerfile
container_name: hello-gin-api
ports:
- "8080:8080"
environment:
# 应用配置
- APP_NAME=hello-gin
- APP_ENV=production
- APP_DEBUG=false
- APP_HOST=0.0.0.0
- APP_PORT=8080
# 数据库配置(与下面的 mysql 服务匹配)
- DB_DRIVER=mysql
- DB_HOST=mysql
- DB_PORT=3306
- DB_DATABASE=hello_gin
- DB_USERNAME=appuser
- DB_PASSWORD=apppassword
- DB_MAX_OPEN_CONNS=100
- DB_MAX_IDLE_CONNS=10
- DB_CONN_MAX_LIFETIME=3600
# Redis 配置(与下面的 redis 服务匹配)
- REDIS_HOST=redis
- REDIS_PORT=6379
- REDIS_PASSWORD=
- REDIS_DB=0
- REDIS_POOL_SIZE=10
# JWT 配置
- JWT_ACCESS_SECRET=14dd732bd4336f34ca74eb4c013f15ffd421f9d6ab68f2e09a134caaef5302b7
- JWT_ACCESS_EXPIRE=7200
- JWT_REFRESH_SECRET=97281e77751e72f99e9a1315190db3e7c7bebb225a98472cef98b9d015ea2010
- JWT_REFRESH_EXPIRE=604800
# 兼容旧配置
- JWT_SECRET=c140033ca99a3d692dedd857e80655e6e4f79da8b8a1c4d310a4df861565738d
- JWT_EXPIRE=7200
# 日志配置
- LOG_LEVEL=info
- LOG_PATH=./logs
- LOG_MAX_SIZE=100
- LOG_MAX_BACKUPS=7
- LOG_MAX_AGE=30
# Gin 模式
- GIN_MODE=release
# 注意:如果需要自定义配置,可以创建 .env 文件并取消下面的注释
# env_file:
# - .env
depends_on:
mysql:
condition: service_healthy
redis:
condition: service_healthy
networks:
- app-network
restart: unless-stopped
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:8080/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
mysql:
image: mysql:8.0
container_name: hello-gin-mysql
environment:
MYSQL_ROOT_PASSWORD: rootpassword
MYSQL_DATABASE: hello_gin
MYSQL_USER: appuser
MYSQL_PASSWORD: apppassword
ports:
- "3306:3306"
volumes:
- mysql_data:/var/lib/mysql
- ./scripts/init.sql:/docker-entrypoint-initdb.d/init.sql
networks:
- app-network
restart: unless-stopped
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
interval: 10s
timeout: 5s
retries: 5
redis:
image: redis:7-alpine
container_name: hello-gin-redis
ports:
- "6379:6379"
volumes:
- redis_data:/data
networks:
- app-network
restart: unless-stopped
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
phpmyadmin:
image: phpmyadmin:latest
container_name: hello-gin-phpmyadmin
ports:
- "8081:80"
environment:
PMA_HOST: mysql
PMA_PORT: 3306
PMA_USER: root
PMA_PASSWORD: rootpassword
MYSQL_ROOT_PASSWORD: rootpassword
UPLOAD_LIMIT: 300M
depends_on:
mysql:
condition: service_healthy
networks:
- app-network
restart: unless-stopped
nginx:
image: nginx:alpine
container_name: hello-gin-nginx
ports:
- "80:80"
- "443:443"
volumes:
- ./config/nginx/nginx.conf:/etc/nginx/nginx.conf
- ./config/nginx/conf.d:/etc/nginx/conf.d
depends_on:
api:
condition: service_healthy
networks:
- app-network
restart: unless-stopped
networks:
app-network:
driver: bridge
volumes:
mysql_data:
redis_data: