by-crm/docker-compose.yml
2026-01-26 16:45:05 +08:00

88 lines
2.0 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

version: '3.8'
networks:
crm_network:
driver: bridge
ipam:
config:
- subnet: 192.168.100.0/24
services:
# MySQL 数据库
crm-mysql:
image: mysql:8
container_name: crm-mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: MySQL123s56
MYSQL_DATABASE: crm_db
TZ: Asia/Shanghai
ports:
- "3306:3306"
volumes:
- ./mysql/data:/var/lib/mysql
- ./sql/init.sql:/docker-entrypoint-initdb.d/init.sql:ro
networks:
- crm_network
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-pMySQL123s56"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
# 后端服务
crm-backend:
build:
context: ./backend
dockerfile: Dockerfile
container_name: crm-backend
restart: always
depends_on:
crm-mysql:
condition: service_healthy
environment:
# 数据库配置
SPRING_DATASOURCE_URL: jdbc:mysql://crm-mysql:3306/crm_db?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai
SPRING_DATASOURCE_USERNAME: root
SPRING_DATASOURCE_PASSWORD: MySQL123s56
# JWT 配置
JWT_SECRET: your-secret-key-change-in-production
JWT_EXPIRATION: 86400000
# 应用配置
SERVER_PORT: 8080
TZ: Asia/Shanghai
ports:
- "8080:8080"
volumes:
- ./backend/logs:/app/logs
networks:
- crm_network
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:8080/actuator/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
# 前端服务Nginx
crm-frontend:
build:
context: ./frontend
dockerfile: Dockerfile
container_name: crm-frontend
restart: always
depends_on:
- crm-backend
ports:
- "80:80"
networks:
- crm_network
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:80"]
interval: 30s
timeout: 5s
retries: 3