- 完整的Next.js 14 + TypeScript项目架构 - 集成Three.js和GSAP用于3D渲染和动画 - Prisma ORM + PostgreSQL数据库 - Docker容器化部署支持 - 本地缓存优化系统 - 中文界面和注释 - 移动端响应式设计 - 健康检查和监控功能
160 lines
4.4 KiB
YAML
160 lines
4.4 KiB
YAML
# ============================================
|
|
# 3D家具安装展示系统 - 缓存优化版Docker Compose
|
|
# 使用本地缓存加速构建和部署
|
|
# ============================================
|
|
|
|
version: '3.8'
|
|
|
|
services:
|
|
# PostgreSQL 数据库
|
|
postgres:
|
|
image: postgres:15-alpine
|
|
container_name: furniture-3d-postgres
|
|
environment:
|
|
POSTGRES_DB: furniture_3d
|
|
POSTGRES_USER: furniture_user
|
|
POSTGRES_PASSWORD: furniture_pass_2024
|
|
POSTGRES_INITDB_ARGS: "--encoding=UTF-8 --lc-collate=C --lc-ctype=C"
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
- ./cache/postgres-init:/docker-entrypoint-initdb.d:ro
|
|
ports:
|
|
- "5432:5432"
|
|
networks:
|
|
- furniture-network
|
|
restart: unless-stopped
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U furniture_user -d furniture_3d"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
# MinIO 对象存储
|
|
minio:
|
|
image: minio/minio:latest
|
|
container_name: furniture-3d-minio
|
|
environment:
|
|
MINIO_ROOT_USER: minioadmin
|
|
MINIO_ROOT_PASSWORD: minioadmin
|
|
MINIO_BROWSER_REDIRECT_URL: http://localhost:9001
|
|
volumes:
|
|
- minio_data:/data
|
|
- ./cache/minio-config:/root/.minio:ro
|
|
ports:
|
|
- "9000:9000"
|
|
- "9001:9001"
|
|
networks:
|
|
- furniture-network
|
|
command: server /data --console-address ":9001"
|
|
restart: unless-stopped
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
|
|
interval: 30s
|
|
timeout: 20s
|
|
retries: 3
|
|
|
|
# 3D家具展示应用
|
|
app:
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile.optimized
|
|
args:
|
|
DATABASE_URL: postgresql://furniture_user:furniture_pass_2024@postgres:5432/furniture_3d
|
|
NEXTAUTH_URL: http://localhost:3000
|
|
APP_PUBLIC_URL: http://localhost:3000
|
|
# 使用缓存挂载加速构建
|
|
cache_from:
|
|
- node:18-alpine
|
|
target: runner
|
|
container_name: furniture-3d-app
|
|
environment:
|
|
# 数据库配置
|
|
DATABASE_URL: postgresql://furniture_user:furniture_pass_2024@postgres:5432/furniture_3d
|
|
|
|
# 认证配置
|
|
NEXTAUTH_SECRET: furniture-3d-secret-key-2024
|
|
NEXTAUTH_URL: http://localhost:3000
|
|
APP_PUBLIC_URL: http://localhost:3000
|
|
|
|
# MinIO/S3配置
|
|
S3_ENDPOINT: http://minio:9000
|
|
S3_BUCKET: furniture-3d-models
|
|
S3_ACCESS_KEY: minioadmin
|
|
S3_SECRET_KEY: minioadmin
|
|
S3_REGION: us-east-1
|
|
S3_FORCE_PATH_STYLE: "true"
|
|
|
|
# 应用配置
|
|
NODE_ENV: production
|
|
PORT: 3000
|
|
|
|
# 3D渲染优化
|
|
NEXT_SHARP: 0
|
|
NEXT_TELEMETRY_DISABLED: 1
|
|
volumes:
|
|
- app_uploads:/app/uploads
|
|
# 挂载本地缓存(只读)
|
|
- ./cache/prisma-engines:/app/prisma/engine-cache:ro
|
|
ports:
|
|
- "3000:3000"
|
|
networks:
|
|
- furniture-network
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
minio:
|
|
condition: service_healthy
|
|
restart: unless-stopped
|
|
healthcheck:
|
|
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3000/api/health"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
start_period: 40s
|
|
|
|
# MinIO 初始化服务(创建存储桶等)
|
|
minio-init:
|
|
image: minio/mc:latest
|
|
container_name: furniture-3d-minio-init
|
|
environment:
|
|
MINIO_ENDPOINT: http://minio:9000
|
|
MINIO_ACCESS_KEY: minioadmin
|
|
MINIO_SECRET_KEY: minioadmin
|
|
networks:
|
|
- furniture-network
|
|
depends_on:
|
|
minio:
|
|
condition: service_healthy
|
|
entrypoint: >
|
|
/bin/sh -c "
|
|
echo '🔧 配置MinIO客户端...'
|
|
mc alias set furniture http://minio:9000 minioadmin minioadmin
|
|
|
|
echo '📦 创建存储桶...'
|
|
mc mb furniture/furniture-3d-models --ignore-existing
|
|
mc mb furniture/furniture-3d-thumbnails --ignore-existing
|
|
mc mb furniture/furniture-3d-cache --ignore-existing
|
|
|
|
echo '🔒 设置存储桶策略...'
|
|
mc anonymous set public furniture/furniture-3d-models
|
|
mc anonymous set public furniture/furniture-3d-thumbnails
|
|
|
|
echo '✅ MinIO初始化完成'
|
|
"
|
|
restart: "no"
|
|
|
|
volumes:
|
|
postgres_data:
|
|
driver: local
|
|
name: furniture-3d-postgres-data
|
|
minio_data:
|
|
driver: local
|
|
name: furniture-3d-minio-data
|
|
app_uploads:
|
|
driver: local
|
|
name: furniture-3d-app-uploads
|
|
|
|
networks:
|
|
furniture-network:
|
|
driver: bridge
|
|
name: furniture-3d-network |