flnxi-Wu/docker-compose.prod.yml
WuYongJie d1c6efc79d
Some checks failed
CI Check / check (push) Has been cancelled
feat: NAS 部署与 Harbor 推送流程
2025-12-03 14:39:06 +08:00

133 lines
4.5 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'
# ============================================
# FLNXI素材库 - Pro版配置
# 支持内网穿透,资源存储在MinIO存储桶
# 从私有镜像仓库拉取镜像,无需源码
# ============================================
services:
# PostgreSQL 数据库
postgres:
# 从 Harbor 的 runtime 子目录拉取(正式环境使用公开镜像)
image: ${POSTGRES_IMAGE:-harbor.flnxi.com/flnxi/runtime/postgres:15-alpine}
container_name: flnxi-postgres
restart: unless-stopped
environment:
POSTGRES_USER: ${POSTGRES_USER:-postgres}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-youyidian123456}
POSTGRES_DB: ${POSTGRES_DB:-flnxi}
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:
# 从 Harbor 的 flnxi 项目下的 runtime 子目录拉取
image: ${MINIO_IMAGE:-harbor.flnxi.com/flnxi/runtime/minio:RELEASE.2025-04-22T22-12-26Z}
container_name: flnxi-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:
# 从 Harbor 的 flnxi 项目下的 runtime 子目录拉取
image: ${MINIO_MC_IMAGE:-harbor.flnxi.com/flnxi/runtime/minio-mc:latest}
container_name: flnxi-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:-flnxi-materials} --ignore-existing;
mc anonymous set download myminio/${S3_BUCKET:-flnxi-materials};
echo 'MinIO bucket created and configured successfully';
exit 0;
"
networks:
- app-network
# 主应用(Pro版 - 从私有镜像仓库拉取)
app:
# 根据环境从不同的 Harbor 项目拉取:
# - 测试环境: harbor.flnxi.com/flnxi-test/flnxi-material:pro-test (私有,需登录)
# - 正式环境: harbor.flnxi.com/flnxi/flnxi-material:pro-latest (公开,无需登录)
image: ${APP_IMAGE:-${DOCKER_REGISTRY:-harbor.flnxi.com/flnxi}/flnxi-material:pro-${IMAGE_TAG:-latest}}
container_name: flnxi-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:-flnxi}
- DATABASE_DRIVER=node
- STORAGE_PROVIDER=s3
- S3_ENDPOINT=http://minio:9000
- S3_BUCKET=${S3_BUCKET:-flnxi-materials}
- 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:-127.0.0.1}:${MINIO_API_PORT:-9000}/${S3_BUCKET:-flnxi-materials}
- 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