100 lines
3.2 KiB
YAML
100 lines
3.2 KiB
YAML
# CloudNest 基础设施 Docker Compose
|
||
# CloudNest Infrastructure Docker Compose
|
||
# 包含 MySQL / Redis / MinIO 三个基础设施服务
|
||
# Contains MySQL / Redis / MinIO infrastructure services
|
||
|
||
# 启动方式 / Startup:
|
||
# docker compose -f docker-compose.infra.yml up -d
|
||
# 停止方式 / Stop:
|
||
# docker compose -f docker-compose.infra.yml down
|
||
# 查看日志 / View logs:
|
||
# docker compose -f docker-compose.infra.yml logs -f
|
||
|
||
# 环境变量说明 / Environment variables:
|
||
# DB_HOST - MySQL 主机(默认:容器内主机名 mysql)
|
||
# DB_PORT - MySQL 端口(默认:3306)
|
||
# DB_USER - MySQL 用户(默认:root)
|
||
# DB_PASSWORD - MySQL 密码(默认:sun900120)
|
||
# DB_NAME - 数据库名(默认:cloudnest)
|
||
# REDIS_PORT - Redis 端口(默认:6379)
|
||
# MINIO_PORT - MinIO API 端口(默认:9000)
|
||
# MINIO_CONSOLE_PORT - MinIO 控制台端口(默认:9001)
|
||
# MINIO_ACCESS_KEY - MinIO 访问密钥(默认:minioadmin)
|
||
# MINIO_SECRET_KEY - MinIO 秘密密钥(默认:minioadmin)
|
||
|
||
version: "3.8"
|
||
|
||
services:
|
||
mysql:
|
||
image: mysql:8.0
|
||
container_name: cloudnest-mysql
|
||
environment:
|
||
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD:-sun900120}
|
||
MYSQL_DATABASE: ${DB_NAME:-cloudnest}
|
||
ports:
|
||
- "${DB_PORT:-3306}:3306"
|
||
volumes:
|
||
- mysql-data:/var/lib/mysql
|
||
# 可选:挂载初始化脚本目录 / Optional: mount init scripts
|
||
# - ./scripts/mysql/init:/docker-entrypoint-initdb.d
|
||
networks:
|
||
- cloudnest-network
|
||
restart: unless-stopped
|
||
healthcheck:
|
||
test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "-uroot", "-p${DB_PASSWORD:-sun900120}"]
|
||
interval: 10s
|
||
timeout: 5s
|
||
retries: 5
|
||
start_period: 30s
|
||
command: --default-authentication-plugin=caching_sha2_password --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
|
||
|
||
redis:
|
||
image: redis:7-alpine
|
||
container_name: cloudnest-redis
|
||
ports:
|
||
- "${REDIS_PORT:-6379}:6379"
|
||
networks:
|
||
- cloudnest-network
|
||
restart: unless-stopped
|
||
healthcheck:
|
||
test: ["CMD", "redis-cli", "ping"]
|
||
interval: 5s
|
||
timeout: 3s
|
||
retries: 5
|
||
# 可选:挂载 Redis 配置文件 / Optional: mount redis config
|
||
# volumes:
|
||
# - ./configs/redis.conf:/usr/local/etc/redis/redis.conf
|
||
# command: redis-server /usr/local/etc/redis/redis.conf
|
||
|
||
minio:
|
||
image: minio/minio:latest
|
||
container_name: cloudnest-minio
|
||
command: server /data --console-address ":9001"
|
||
environment:
|
||
MINIO_ROOT_USER: ${MINIO_ACCESS_KEY:-minioadmin}
|
||
MINIO_ROOT_PASSWORD: ${MINIO_SECRET_KEY:-minioadmin}
|
||
ports:
|
||
- "${MINIO_PORT:-9000}:9000"
|
||
- "${MINIO_CONSOLE_PORT:-9001}:9001"
|
||
volumes:
|
||
- minio-data:/data
|
||
networks:
|
||
- cloudnest-network
|
||
restart: unless-stopped
|
||
healthcheck:
|
||
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
|
||
interval: 10s
|
||
timeout: 5s
|
||
retries: 5
|
||
start_period: 10s
|
||
|
||
volumes:
|
||
mysql-data:
|
||
name: cloudnest-mysql-data
|
||
minio-data:
|
||
name: cloudnest-minio-data
|
||
|
||
networks:
|
||
cloudnest-network:
|
||
name: cloudnest-network
|
||
driver: bridge |