110 lines
2.5 KiB
YAML
110 lines
2.5 KiB
YAML
version: '3.8'
|
|
|
|
services:
|
|
# MySQL 数据库
|
|
mysql:
|
|
image: mysql:8.0
|
|
container_name: wecom-mysql
|
|
restart: always
|
|
environment:
|
|
MYSQL_ROOT_PASSWORD: ash@szmp
|
|
MYSQL_DATABASE: ash-vue
|
|
MYSQL_USER: ash
|
|
MYSQL_PASSWORD: ash@szmp
|
|
TZ: Asia/Shanghai
|
|
ports:
|
|
- "3306:3306"
|
|
volumes:
|
|
- mysql_data:/var/lib/mysql
|
|
- mysql_conf:/etc/mysql/conf.d
|
|
command: --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
|
|
networks:
|
|
- wecom-network
|
|
healthcheck:
|
|
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-uroot", "-pash@szmp"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
# Redis 缓存
|
|
redis:
|
|
image: redis:7-alpine
|
|
container_name: wecom-redis
|
|
restart: always
|
|
ports:
|
|
- "6379:6379"
|
|
volumes:
|
|
- redis_data:/data
|
|
command: redis-server --appendonly yes --requirepass ash@szmp
|
|
networks:
|
|
- wecom-network
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
# 后端服务
|
|
backend:
|
|
build:
|
|
context: ./backend
|
|
dockerfile: Dockerfile
|
|
container_name: wecom-backend
|
|
restart: always
|
|
ports:
|
|
- "8888:8888"
|
|
volumes:
|
|
- upload_data:/home/ash/uploadPath
|
|
environment:
|
|
SPRING_DATASOURCE_URL: jdbc:mysql://mysql:3306/ash-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
|
SPRING_DATASOURCE_USERNAME: ash
|
|
SPRING_DATASOURCE_PASSWORD: ash@szmp
|
|
SPRING_REDIS_HOST: redis
|
|
SPRING_REDIS_PORT: 6379
|
|
SPRING_REDIS_PASSWORD: ash@szmp
|
|
depends_on:
|
|
mysql:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
extra_hosts:
|
|
- "host.docker.internal:host-gateway"
|
|
networks:
|
|
- wecom-network
|
|
healthcheck:
|
|
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:8888/"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
|
|
# 前端服务
|
|
frontend:
|
|
build:
|
|
context: ./frontend
|
|
dockerfile: Dockerfile
|
|
container_name: wecom-frontend
|
|
restart: always
|
|
ports:
|
|
- "8889:80"
|
|
depends_on:
|
|
backend:
|
|
condition: service_healthy
|
|
networks:
|
|
- wecom-network
|
|
|
|
# 数据卷
|
|
volumes:
|
|
mysql_data:
|
|
driver: local
|
|
mysql_conf:
|
|
driver: local
|
|
redis_data:
|
|
driver: local
|
|
upload_data:
|
|
driver: local
|
|
|
|
# 网络
|
|
networks:
|
|
wecom-network:
|
|
driver: bridge
|