188 lines
5.3 KiB
YAML
188 lines
5.3 KiB
YAML
version: '3.8'
|
||
|
||
services:
|
||
# ============================================
|
||
# 基础设施
|
||
# ============================================
|
||
|
||
postgres:
|
||
image: postgres:16-alpine
|
||
container_name: youdu-wiki-postgres
|
||
restart: unless-stopped
|
||
environment:
|
||
POSTGRES_USER: youdu-wiki
|
||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-ChangeMe123!}
|
||
POSTGRES_DB: youdu-wiki
|
||
volumes:
|
||
- pg_data:/var/lib/postgresql/data
|
||
networks:
|
||
- youdu-wiki
|
||
healthcheck:
|
||
test: ["CMD-SHELL", "pg_isready -U youdu-wiki"]
|
||
interval: 5s
|
||
timeout: 5s
|
||
retries: 10
|
||
|
||
redis:
|
||
image: redis:7-alpine
|
||
container_name: youdu-wiki-redis
|
||
restart: unless-stopped
|
||
command: redis-server --appendonly yes --requirepass ${REDIS_PASSWORD:-ChangeMe123!}
|
||
volumes:
|
||
- redis_data:/data
|
||
networks:
|
||
- youdu-wiki
|
||
healthcheck:
|
||
test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD:-ChangeMe123!}", "ping"]
|
||
interval: 5s
|
||
timeout: 5s
|
||
retries: 10
|
||
|
||
nats:
|
||
image: nats:2-alpine
|
||
container_name: youdu-wiki-nats
|
||
restart: unless-stopped
|
||
command: >
|
||
-js
|
||
-m 8222
|
||
--user ${NATS_USER:-youdu-wiki}
|
||
--pass ${NATS_PASSWORD:-ChangeMe123!}
|
||
networks:
|
||
- youdu-wiki
|
||
|
||
minio:
|
||
image: minio/minio:latest
|
||
container_name: youdu-wiki-minio
|
||
restart: unless-stopped
|
||
command: server /data --console-address ":9001"
|
||
environment:
|
||
MINIO_ROOT_USER: ${S3_ACCESS_KEY:-s3youdu-wiki}
|
||
MINIO_ROOT_PASSWORD: ${S3_SECRET_KEY:-ChangeMe123!}
|
||
volumes:
|
||
- minio_data:/data
|
||
networks:
|
||
- youdu-wiki
|
||
healthcheck:
|
||
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
|
||
interval: 10s
|
||
timeout: 5s
|
||
retries: 10
|
||
|
||
# ============================================
|
||
# 后端服务
|
||
# ============================================
|
||
|
||
api:
|
||
build:
|
||
context: ./backend
|
||
dockerfile: Dockerfile.api
|
||
image: youdu-wiki-api:${TAG:-latest}
|
||
container_name: youdu-wiki-api
|
||
restart: unless-stopped
|
||
environment:
|
||
PG_DSN: "host=youdu-wiki-postgres user=youdu-wiki password=${POSTGRES_PASSWORD:-ChangeMe123!} dbname=youdu-wiki port=5432 sslmode=disable TimeZone=Asia/Shanghai"
|
||
MQ_NATS_SERVER: "nats://youdu-wiki-nats:4222"
|
||
NATS_USER: ${NATS_USER:-youdu-wiki}
|
||
NATS_PASSWORD: ${NATS_PASSWORD:-ChangeMe123!}
|
||
REDIS_ADDR: "youdu-wiki-redis:6379"
|
||
REDIS_PASSWORD: ${REDIS_PASSWORD:-ChangeMe123!}
|
||
S3_ENDPOINT: "youdu-wiki-minio:9000"
|
||
S3_ACCESS_KEY: ${S3_ACCESS_KEY:-s3youdu-wiki}
|
||
S3_SECRET_KEY: ${S3_SECRET_KEY:-ChangeMe123!}
|
||
JWT_SECRET: ${JWT_SECRET:-$(openssl rand -hex 32)}
|
||
ADMIN_PASSWORD: ${ADMIN_PASSWORD:-admin123}
|
||
RAG_CT_RAG_BASE_URL: ${RAG_BASE_URL:-http://host.docker.internal:5050}
|
||
LOG_LEVEL: ${LOG_LEVEL:-0}
|
||
ENV: ${ENV:-production}
|
||
SENTRY_ENABLED: "false"
|
||
ports:
|
||
- "${API_PORT:-8000}:8000"
|
||
networks:
|
||
- youdu-wiki
|
||
depends_on:
|
||
postgres:
|
||
condition: service_healthy
|
||
redis:
|
||
condition: service_healthy
|
||
minio:
|
||
condition: service_healthy
|
||
|
||
consumer:
|
||
build:
|
||
context: ./backend
|
||
dockerfile: Dockerfile.consumer
|
||
image: youdu-wiki-consumer:${TAG:-latest}
|
||
container_name: youdu-wiki-consumer
|
||
restart: unless-stopped
|
||
environment:
|
||
PG_DSN: "host=youdu-wiki-postgres user=youdu-wiki password=${POSTGRES_PASSWORD:-ChangeMe123!} dbname=youdu-wiki port=5432 sslmode=disable TimeZone=Asia/Shanghai"
|
||
MQ_NATS_SERVER: "nats://youdu-wiki-nats:4222"
|
||
NATS_USER: ${NATS_USER:-youdu-wiki}
|
||
NATS_PASSWORD: ${NATS_PASSWORD:-ChangeMe123!}
|
||
REDIS_ADDR: "youdu-wiki-redis:6379"
|
||
REDIS_PASSWORD: ${REDIS_PASSWORD:-ChangeMe123!}
|
||
S3_ENDPOINT: "youdu-wiki-minio:9000"
|
||
S3_ACCESS_KEY: ${S3_ACCESS_KEY:-s3youdu-wiki}
|
||
S3_SECRET_KEY: ${S3_SECRET_KEY:-ChangeMe123!}
|
||
JWT_SECRET: ${JWT_SECRET:-$(openssl rand -hex 32)}
|
||
RAG_CT_RAG_BASE_URL: ${RAG_BASE_URL:-http://host.docker.internal:5050}
|
||
LOG_LEVEL: ${LOG_LEVEL:-0}
|
||
ENV: ${ENV:-production}
|
||
SENTRY_ENABLED: "false"
|
||
networks:
|
||
- youdu-wiki
|
||
depends_on:
|
||
postgres:
|
||
condition: service_healthy
|
||
redis:
|
||
condition: service_healthy
|
||
|
||
# ============================================
|
||
# 前端 - 管理后台 (Nginx + React)
|
||
# 容器内 Nginx 监听 8080,对外暴露 ${ADMIN_PORT:-2443}
|
||
# ============================================
|
||
|
||
admin:
|
||
build:
|
||
context: ./web
|
||
dockerfile: Dockerfile.admin
|
||
image: youdu-wiki-admin:${TAG:-latest}
|
||
container_name: youdu-wiki-admin
|
||
restart: unless-stopped
|
||
ports:
|
||
- "${ADMIN_PORT:-2443}:8080"
|
||
networks:
|
||
- youdu-wiki
|
||
depends_on:
|
||
- api
|
||
|
||
# ============================================
|
||
# 前端 - Wiki 用户端 (Next.js)
|
||
# ============================================
|
||
|
||
app:
|
||
build:
|
||
context: ./web
|
||
dockerfile: Dockerfile.app
|
||
image: youdu-wiki-app:${TAG:-latest}
|
||
container_name: youdu-wiki-app
|
||
restart: unless-stopped
|
||
ports:
|
||
- "${APP_PORT:-3010}:3010"
|
||
networks:
|
||
- youdu-wiki
|
||
depends_on:
|
||
- api
|
||
|
||
volumes:
|
||
pg_data:
|
||
driver: local
|
||
redis_data:
|
||
driver: local
|
||
minio_data:
|
||
driver: local
|
||
|
||
networks:
|
||
youdu-wiki:
|
||
driver: bridge
|