80 lines
2.4 KiB
YAML
80 lines
2.4 KiB
YAML
# Nacos Standalone Mode - Docker Compose
|
||
# 适用于开发/测试环境,单节点部署
|
||
version: '3.8'
|
||
|
||
services:
|
||
# MySQL for Nacos Persistence (可选,如果使用内置Derby可以注释掉)
|
||
nacos-mysql:
|
||
image: mysql:8.0
|
||
container_name: erp-nacos-mysql
|
||
environment:
|
||
MYSQL_ROOT_PASSWORD: root123456
|
||
MYSQL_DATABASE: nacos_config
|
||
MYSQL_USER: nacos
|
||
MYSQL_PASSWORD: nacos123456
|
||
ports:
|
||
- "3308:3306"
|
||
volumes:
|
||
- nacos_mysql_data:/var/lib/mysql
|
||
- ./init/mysql-schema.sql:/docker-entrypoint-initdb.d/mysql-schema.sql
|
||
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --default-authentication-plugin=mysql_native_password
|
||
networks:
|
||
- nacos-network
|
||
healthcheck:
|
||
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-uroot", "-proot123456"]
|
||
interval: 10s
|
||
timeout: 5s
|
||
retries: 5
|
||
|
||
# Nacos Server (Standalone with MySQL)
|
||
nacos-server:
|
||
image: nacos/nacos-server:v2.2.3
|
||
container_name: erp-nacos-server
|
||
environment:
|
||
# 运行模式:standalone 单机 / cluster 集群
|
||
MODE: standalone
|
||
# MySQL持久化配置
|
||
SPRING_DATASOURCE_PLATFORM: mysql
|
||
MYSQL_SERVICE_HOST: nacos-mysql
|
||
MYSQL_SERVICE_DB_NAME: nacos_config
|
||
MYSQL_SERVICE_PORT: 3306
|
||
MYSQL_SERVICE_USER: nacos
|
||
MYSQL_SERVICE_PASSWORD: nacos123456
|
||
# 认证配置(生产环境务必修改)
|
||
NACOS_AUTH_ENABLE: "true"
|
||
NACOS_AUTH_TOKEN: "SecretKey012345678901234567890123456789012345678901234567890123456789"
|
||
NACOS_AUTH_IDENTITY_KEY: "serverIdentity"
|
||
NACOS_AUTH_IDENTITY_VALUE: "security"
|
||
# JVM调优(开发环境可适当降低)
|
||
JVM_XMS: 512m
|
||
JVM_XMX: 512m
|
||
JVM_XMN: 256m
|
||
ports:
|
||
- "8848:8848" # 主端口
|
||
- "9848:9848" # gRPC端口(客户端gRPC请求)
|
||
- "9849:9849" # gRPC端口(集群间通信)
|
||
volumes:
|
||
- nacos_logs:/home/nacos/logs
|
||
- nacos_data:/home/nacos/data
|
||
depends_on:
|
||
nacos-mysql:
|
||
condition: service_healthy
|
||
networks:
|
||
- nacos-network
|
||
restart: unless-stopped
|
||
healthcheck:
|
||
test: ["CMD", "curl", "-f", "http://localhost:8848/nacos/v1/console/health/readiness"]
|
||
interval: 15s
|
||
timeout: 10s
|
||
retries: 10
|
||
start_period: 30s
|
||
|
||
volumes:
|
||
nacos_mysql_data:
|
||
nacos_logs:
|
||
nacos_data:
|
||
|
||
networks:
|
||
nacos-network:
|
||
driver: bridge
|