flnxi-Wu/docker-compose.prod.yml
WuYongJie f646b71813
Some checks failed
CI Check / check (push) Has been cancelled
chore: 初始化本地仓库并同步最近改动
2025-11-18 17:50:16 +08:00

125 lines
3.9 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

version: '3.8'
# ============================================
# 由壹点3D素材 - Pro版配置
# 支持内网穿透,资源存储在MinIO存储桶
# 从私有镜像仓库拉取镜像,无需源码
# ============================================
services:
# PostgreSQL 数据库
postgres:
image: postgres:15-alpine
container_name: youyidian-postgres
restart: unless-stopped
environment:
POSTGRES_USER: ${POSTGRES_USER:-postgres}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-youyidian123456}
POSTGRES_DB: ${POSTGRES_DB:-youyidian3d}
POSTGRES_INITDB_ARGS: "--encoding=UTF-8"
volumes:
- postgres_data:/var/lib/postgresql/data
networks:
- app-network
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-postgres}"]
interval: 10s
timeout: 5s
retries: 5
# MinIO 对象存储
# 使用特定版本号确保稳定性(符合项目宗旨:稳定性优先)
minio:
image: minio/minio:RELEASE.2025-04-22T22-12-26Z
container_name: youyidian-minio
restart: unless-stopped
command: server /data --console-address ":9001"
environment:
MINIO_ROOT_USER: ${MINIO_ROOT_USER:-minioadmin}
MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD:-minioadmin123456}
volumes:
- minio_data:/data
ports:
- "${MINIO_API_PORT:-9000}:9000"
- "${MINIO_CONSOLE_PORT:-9001}:9001"
networks:
- app-network
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
interval: 30s
timeout: 20s
retries: 3
# MinIO 初始化服务(创建bucket)
# 使用 latest 标签确保可用性(mc 客户端版本兼容性好)
minio-init:
image: minio/mc:latest
container_name: youyidian-minio-init
depends_on:
minio:
condition: service_healthy
entrypoint: >
/bin/sh -c "
sleep 5;
mc alias set myminio http://minio:9000 ${MINIO_ROOT_USER:-minioadmin} ${MINIO_ROOT_PASSWORD:-minioadmin123456};
mc mb myminio/${S3_BUCKET:-youyidian3d} --ignore-existing;
mc anonymous set download myminio/${S3_BUCKET:-youyidian3d};
echo 'MinIO bucket created and configured successfully';
exit 0;
"
networks:
- app-network
# 主应用(Pro版 - 从私有镜像仓库拉取)
app:
image: ${DOCKER_REGISTRY:-your-registry.com}/youyidian-3d-material:pro-${IMAGE_TAG:-latest}
container_name: youyidian-3d-material
restart: unless-stopped
ports:
- "${APP_PORT:-4320}:3000"
environment:
- NODE_ENV=production
- DATABASE_URL=postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-youyidian123456}@postgres:5432/${POSTGRES_DB:-youyidian3d}
- DATABASE_DRIVER=node
- STORAGE_PROVIDER=s3
- S3_ENDPOINT=http://minio:9000
- S3_BUCKET=${S3_BUCKET:-youyidian3d}
- S3_ACCESS_KEY_ID=${MINIO_ROOT_USER:-minioadmin}
- S3_SECRET_ACCESS_KEY=${MINIO_ROOT_PASSWORD:-minioadmin123456}
- S3_REGION=us-east-1
- S3_PUBLIC_DOMAIN=http://${SERVER_IP:-45.249.208.118}:${MINIO_API_PORT:-9000}/${S3_BUCKET:-youyidian3d}
- S3_ENABLE_PATH_STYLE=1
- S3_SET_ACL=1
- S3_PREVIEW_URL_EXPIRE_IN=7200
- S3_FILE_PATH=materials/
- NEXT_PUBLIC_S3_FILE_PATH=materials/
- NEXTAUTH_URL=http://${SERVER_IP:-localhost}:${APP_PORT:-4320}
- NEXTAUTH_SECRET=${NEXTAUTH_SECRET:-change-this-to-a-random-string-in-production}
volumes:
- ./uploads:/app/uploads
depends_on:
postgres:
condition: service_healthy
minio:
condition: service_healthy
minio-init:
condition: service_completed_successfully
networks:
- app-network
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3000/api/health"]
interval: 30s
timeout: 10s
retries: 3
volumes:
postgres_data:
driver: local
minio_data:
driver: local
networks:
app-network:
driver: bridge