113 lines
3.0 KiB
YAML
113 lines
3.0 KiB
YAML
version: '3.8'
|
|
|
|
services:
|
|
# MySQL 数据库
|
|
mysql:
|
|
image: swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/mysql:8.0
|
|
container_name: nex-docus-mysql
|
|
restart: unless-stopped
|
|
environment:
|
|
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-root_password_change_me}
|
|
MYSQL_DATABASE: ${DB_NAME:-nex_docus}
|
|
MYSQL_USER: ${DB_USER:-nexdocus}
|
|
MYSQL_PASSWORD: ${DB_PASSWORD:-password_change_me}
|
|
TZ: Asia/Shanghai
|
|
volumes:
|
|
- mysql_data:/var/lib/mysql
|
|
- ./backend/scripts/init.sql:/docker-entrypoint-initdb.d/init.sql:ro
|
|
ports:
|
|
- "${MYSQL_PORT:-3306}:3306"
|
|
command:
|
|
- --character-set-server=utf8mb4
|
|
- --collation-server=utf8mb4_unicode_ci
|
|
healthcheck:
|
|
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p${MYSQL_ROOT_PASSWORD:-root_password_change_me}"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
# Redis 缓存
|
|
redis:
|
|
image: swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/redis:7-alpine
|
|
container_name: nex-docus-redis
|
|
restart: unless-stopped
|
|
command: redis-server --requirepass ${REDIS_PASSWORD:-redis_password_change_me} --appendonly yes
|
|
environment:
|
|
TZ: Asia/Shanghai
|
|
volumes:
|
|
- redis_data:/data
|
|
ports:
|
|
- "${REDIS_PORT:-6379}:6379"
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "--raw", "incr", "ping"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
# 后端服务
|
|
backend:
|
|
build:
|
|
context: ./backend
|
|
dockerfile: Dockerfile
|
|
container_name: nex-docus-backend
|
|
restart: unless-stopped
|
|
environment:
|
|
- DB_HOST=mysql
|
|
- DB_PORT=3306
|
|
- DB_USER=${DB_USER:-nexdocus}
|
|
- DB_PASSWORD=${DB_PASSWORD:-password_change_me}
|
|
- DB_NAME=${DB_NAME:-nex_docus}
|
|
- REDIS_HOST=redis
|
|
- REDIS_PORT=6379
|
|
- REDIS_PASSWORD=${REDIS_PASSWORD:-redis_password_change_me}
|
|
- REDIS_DB=${REDIS_DB:-8}
|
|
- SECRET_KEY=${SECRET_KEY:-your-secret-key-change-me-in-production}
|
|
- DEBUG=${DEBUG:-false}
|
|
- TZ=Asia/Shanghai
|
|
volumes:
|
|
- ${STORAGE_PATH:-./storage}:/data/nex_docus_store
|
|
- ./backend/logs:/app/logs
|
|
ports:
|
|
- "${BACKEND_PORT:-8000}:8000"
|
|
depends_on:
|
|
mysql:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:8000/docs"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
|
|
# 前端服务
|
|
frontend:
|
|
build:
|
|
context: ./forntend
|
|
dockerfile: Dockerfile
|
|
args:
|
|
- VITE_API_BASE_URL=${VITE_API_BASE_URL:-http://localhost:8000}
|
|
container_name: nex-docus-frontend
|
|
restart: unless-stopped
|
|
environment:
|
|
- TZ=Asia/Shanghai
|
|
ports:
|
|
- "${FRONTEND_PORT:-8080}:80"
|
|
depends_on:
|
|
- backend
|
|
healthcheck:
|
|
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:80"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
|
|
volumes:
|
|
mysql_data:
|
|
driver: local
|
|
redis_data:
|
|
driver: local
|
|
|
|
networks:
|
|
default:
|
|
name: nex-docus-network
|