From 5a856e0b843ffea8db8d995bc87f01a4a8650c6f Mon Sep 17 00:00:00 2001 From: hectorzhao Date: Tue, 7 Jul 2026 15:17:26 +0800 Subject: [PATCH] fix: allow local object storage deployment --- docs/production-deployment.md | 4 ++++ tools/deploy/production-bootstrap.sh | 13 +++++++++++-- tools/deploy/production-deploy.sh | 10 ++++++++-- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/docs/production-deployment.md b/docs/production-deployment.md index 469d9c7..665df14 100644 --- a/docs/production-deployment.md +++ b/docs/production-deployment.md @@ -30,6 +30,8 @@ BRANCH=main PUBLIC_HTTP_PORT=12026 API_PORT=3000 GATEWAY_CMPP_ADDR=0.0.0.0:17890 +OBJECT_STORAGE_DRIVER=minio +OBJECT_STORAGE_LOCAL_ROOT=/var/lib/cmpp-platform/object-storage PROD_ADMIN_EMAIL=admin@example.com PROD_ADMIN_USERNAME=prod_admin PROD_ADMIN_PASSWORD='change-me' @@ -37,6 +39,8 @@ PROD_ADMIN_PASSWORD='change-me' 脚本会安装 Node.js、Go、PostgreSQL、Redis、MinIO、Nginx,创建 systemd 服务,执行 Prisma migrate,构建前端/API/Gateway,并创建平台管理员。Node.js、Go 和 MinIO 下载会按服务器架构自动选择 x64/amd64 或 arm64。 +如生产验证服务器临时无法稳定下载 MinIO,可显式传入 `OBJECT_STORAGE_DRIVER=local`,文件会通过真实 API 保存到服务器本地目录 `OBJECT_STORAGE_LOCAL_ROOT`,`cmpp-minio` 服务会跳过安装和启动。该模式只建议用于验证环境;正式生产建议恢复 `OBJECT_STORAGE_DRIVER=minio`。 + ## 后续发布 ```bash diff --git a/tools/deploy/production-bootstrap.sh b/tools/deploy/production-bootstrap.sh index bb9bda6..fec657a 100644 --- a/tools/deploy/production-bootstrap.sh +++ b/tools/deploy/production-bootstrap.sh @@ -14,6 +14,8 @@ DB_PASSWORD="${DB_PASSWORD:-$(openssl rand -base64 24 | tr -d '\n')}" MINIO_ROOT_USER="${MINIO_ROOT_USER:-cmpp_minio}" MINIO_ROOT_PASSWORD="${MINIO_ROOT_PASSWORD:-$(openssl rand -base64 32 | tr -d '\n')}" MINIO_BUCKET="${MINIO_BUCKET:-cmpp-platform}" +OBJECT_STORAGE_DRIVER="${OBJECT_STORAGE_DRIVER:-minio}" +OBJECT_STORAGE_LOCAL_ROOT="${OBJECT_STORAGE_LOCAL_ROOT:-/var/lib/cmpp-platform/object-storage}" PROD_ADMIN_EMAIL="${PROD_ADMIN_EMAIL:-admin@example.com}" PROD_ADMIN_USERNAME="${PROD_ADMIN_USERNAME:-prod_admin}" PROD_ADMIN_PASSWORD="${PROD_ADMIN_PASSWORD:-$(openssl rand -base64 18 | tr -d '\n')}" @@ -100,6 +102,11 @@ install_go() { } install_minio() { + if [[ "$OBJECT_STORAGE_DRIVER" == "local" ]]; then + log "Skipping MinIO install because OBJECT_STORAGE_DRIVER=local" + mkdir -p "$OBJECT_STORAGE_LOCAL_ROOT" + return + fi local arch case "$(uname -m)" in x86_64|amd64) arch="amd64" ;; @@ -140,7 +147,7 @@ SQL write_env() { log "Writing production environment" - mkdir -p /etc/cmpp-platform "$APP_DIR" "$APP_DIR/logs/api" "$APP_DIR/logs/gateway" "$APP_DIR/backups" + mkdir -p /etc/cmpp-platform "$APP_DIR" "$APP_DIR/logs/api" "$APP_DIR/logs/gateway" "$APP_DIR/backups" "$OBJECT_STORAGE_LOCAL_ROOT" cat >/etc/cmpp-platform/cmpp-platform.env </dev/null || true + systemctl enable --now cmpp-api cmpp-gateway nginx +else + systemctl enable --now cmpp-minio + systemctl restart cmpp-minio + systemctl enable --now cmpp-api cmpp-gateway nginx +fi systemctl restart cmpp-api systemctl restart cmpp-gateway systemctl restart nginx