31 lines
962 B
YAML
31 lines
962 B
YAML
version: '3.8'
|
|
|
|
services:
|
|
mysql:
|
|
image: mysql:8.0
|
|
container_name: campus-activity-mysql
|
|
restart: unless-stopped
|
|
environment:
|
|
MYSQL_ROOT_PASSWORD: root
|
|
MYSQL_DATABASE: campus_activity
|
|
TZ: Asia/Shanghai
|
|
ports:
|
|
- "3306:3306"
|
|
volumes:
|
|
# 初始化 SQL 文件会自动按字母顺序执行
|
|
- ./init.sql:/docker-entrypoint-initdb.d/01-init.sql:ro
|
|
- ./sample_data.sql:/docker-entrypoint-initdb.d/02-sample_data.sql:ro
|
|
# 数据持久化
|
|
- ./mysql:/var/lib/mysql
|
|
command:
|
|
- --character-set-server=utf8mb4
|
|
- --collation-server=utf8mb4_general_ci
|
|
- --default-authentication-plugin=mysql_native_password
|
|
- --init-connect='SET NAMES utf8mb4'
|
|
- --skip-character-set-client-handshake
|
|
healthcheck:
|
|
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-proot"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
start_period: 30s |