feat: initial commit - massive-cloud point cloud processing system
This commit is contained in:
59
docker/Dockerfile.dev
Normal file
59
docker/Dockerfile.dev
Normal file
@@ -0,0 +1,59 @@
|
||||
# 开发镜像(仅 CPU,体积小):Node 22 + Python 3 + cadquery
|
||||
# 需要 Docker 内装配检测 GPU 时改用 docker/Dockerfile.dev.gpu(见 docker-compose.dev.yml)
|
||||
# 使用 glibc(bookworm),便于 cadquery / OCP 的 manylinux 轮子
|
||||
FROM node:22-bookworm-slim
|
||||
|
||||
# cadquery/OCP 会链接 OpenGL 与 X11 客户端库(无显示器也会加载),slim 需一次性装齐
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
python3 \
|
||||
python3-pip \
|
||||
ca-certificates \
|
||||
libgl1 \
|
||||
libglib2.0-0 \
|
||||
libxrender1 \
|
||||
libxext6 \
|
||||
libsm6 \
|
||||
libice6 \
|
||||
libx11-6 \
|
||||
libgomp1 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# 安装 Miniforge(conda-forge 原生,无 Anaconda ToS 限制)用于 pythonocc-core
|
||||
ARG CONDA_INSTALLER_URL=https://mirrors.tuna.tsinghua.edu.cn/github-release/conda-forge/miniforge/LatestRelease/Miniforge3-Linux-x86_64.sh
|
||||
RUN curl -fsSL "${CONDA_INSTALLER_URL}" -o /tmp/miniforge.sh \
|
||||
&& bash /tmp/miniforge.sh -b -p /opt/conda \
|
||||
&& rm /tmp/miniforge.sh \
|
||||
&& PY_VER=$(python3 -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')") \
|
||||
&& /opt/conda/bin/conda config --set channel_priority strict \
|
||||
&& /opt/conda/bin/conda create -y -n occ python="${PY_VER}" pythonocc-core=7.9.3 -c conda-forge \
|
||||
&& /opt/conda/bin/conda clean -afy
|
||||
# 让系统 python3 能找到 pythonocc-core(软链 site-packages)
|
||||
RUN PY_VER=$(python3 -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')") \
|
||||
&& CONDA_SP="/opt/conda/envs/occ/lib/python${PY_VER}/site-packages" \
|
||||
&& SYS_SP=$(python3 -c "import site; print(site.getsitepackages()[0])") \
|
||||
&& ln -sf "${CONDA_SP}/OCC" "${SYS_SP}/OCC"
|
||||
|
||||
# 先安装几何依赖(镜像构建时固化,避免每次 compose up 再 pip)
|
||||
# cadquery-ocp 轮子约 70MB,默认 pip 超时过短会 Read timed out;可调大 PIP_DEFAULT_TIMEOUT
|
||||
# 默认国内 PyPI 源;覆盖示例:--build-arg PIP_INDEX_URL=https://mirrors.aliyun.com/pypi/simple/
|
||||
ARG PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple
|
||||
ARG PIP_DEFAULT_TIMEOUT=300
|
||||
COPY requirements-geometry.txt /tmp/requirements-geometry.txt
|
||||
# 必须用 python3 -m pip,避免 pip3 与 /usr/bin/python3 不是同一套 site-packages(PEP 668 下常见踩坑)
|
||||
RUN python3 -m pip install --no-cache-dir --break-system-packages \
|
||||
--default-timeout="${PIP_DEFAULT_TIMEOUT}" \
|
||||
--retries 10 \
|
||||
-i "${PIP_INDEX_URL}" \
|
||||
-r /tmp/requirements-geometry.txt \
|
||||
&& rm /tmp/requirements-geometry.txt \
|
||||
&& python3 -c "import cadquery; print('cadquery OK:', cadquery.__file__)"
|
||||
|
||||
# Node 子进程解析 STEP 时使用;与 compose 中 PYTHON3_PATH 一致,避免仅 build 镜像未带 compose 时未设置
|
||||
ENV PYTHON3_PATH=/usr/bin/python3
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN corepack enable && corepack prepare pnpm@latest --activate
|
||||
|
||||
# 默认占位;docker-compose.dev.yml 会覆盖为 pnpm dev
|
||||
CMD ["node", "-e", "console.log('use docker-compose command')"]
|
||||
105
docker/Dockerfile.dev.gpu
Normal file
105
docker/Dockerfile.dev.gpu
Normal file
@@ -0,0 +1,105 @@
|
||||
# 开发镜像(GPU):Ubuntu 22.04 + CUDA 12.1 runtime + Node 22 + cadquery + PyTorch(cu121) + PyTorch3D
|
||||
# 用于装配检测「最近零件」服务端 GPU(scripts/assembly_nearest_gpu.py)
|
||||
# 宿主机需:NVIDIA 驱动 + nvidia-container-toolkit;构建不要求 GPU,运行需 --gpus
|
||||
#
|
||||
# 构建:docker build -t massive-point-cloud-app-dev:local -f docker/Dockerfile.dev.gpu .
|
||||
#
|
||||
# 无 NVIDIA 的机器请改用 docker/Dockerfile.dev(仅 CPU),compose 中去掉 gpus 与 ASSEMBLY_USE_GPU
|
||||
|
||||
FROM nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu22.04
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive \
|
||||
PYTHON3_PATH=/usr/bin/python3 \
|
||||
ASSEMBLY_USE_GPU=1 \
|
||||
NVIDIA_VISIBLE_DEVICES=all \
|
||||
NVIDIA_DRIVER_CAPABILITIES=compute,utility
|
||||
|
||||
# apt 换阿里云(国内构建加速);需官方源时可在下方注释掉本段
|
||||
RUN set -eux; \
|
||||
if [ -f /etc/apt/sources.list ]; then \
|
||||
sed -i 's|http://archive.ubuntu.com/ubuntu|http://mirrors.aliyun.com/ubuntu|g' /etc/apt/sources.list; \
|
||||
sed -i 's|http://security.ubuntu.com/ubuntu|http://mirrors.aliyun.com/ubuntu|g' /etc/apt/sources.list; \
|
||||
fi
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
python3 \
|
||||
python3-pip \
|
||||
python3-dev \
|
||||
ca-certificates \
|
||||
curl \
|
||||
gnupg \
|
||||
libgl1 \
|
||||
libglib2.0-0 \
|
||||
libxrender1 \
|
||||
libxext6 \
|
||||
libsm6 \
|
||||
libice6 \
|
||||
libx11-6 \
|
||||
libgomp1 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# CUDA runtime 镜像默认不带 nvidia-smi;装 Ubuntu 的 nvidia-utils(主版本与宿主机驱动大版本一致,如 535/550)
|
||||
# 构建失败时改:--build-arg NVIDIA_UTILS_MAJOR=550
|
||||
ARG NVIDIA_UTILS_MAJOR=535
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
"nvidia-utils-${NVIDIA_UTILS_MAJOR}" \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN mkdir -p /etc/apt/keyrings \
|
||||
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
|
||||
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_22.x nodistro main" > /etc/apt/sources.list.d/nodesource.list \
|
||||
&& apt-get update && apt-get install -y --no-install-recommends nodejs \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN python3 -m pip install --no-cache-dir --upgrade pip setuptools wheel
|
||||
|
||||
# 安装 Miniforge + pythonocc-core(conda-forge,无 Anaconda ToS 限制)
|
||||
ARG MINIFORGE_URL=https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh
|
||||
RUN set -eux \
|
||||
&& curl -fsSL "${MINIFORGE_URL}" -o /tmp/miniforge.sh \
|
||||
&& bash /tmp/miniforge.sh -b -p /opt/conda \
|
||||
&& rm /tmp/miniforge.sh \
|
||||
&& /opt/conda/bin/conda install -y -n base -c conda-forge \
|
||||
"python=3.10" pythonocc-core=7.9.3 \
|
||||
&& /opt/conda/bin/conda clean -afy \
|
||||
&& ln -sf /opt/conda/lib/python3.10/site-packages/OCC \
|
||||
/usr/local/lib/python3.10/dist-packages/OCC
|
||||
# conda-forge 编译的 .so 需要新版 libstdc++;用 conda 自带的覆盖系统库
|
||||
RUN ln -sf /opt/conda/lib/libstdc++.so.6 /usr/lib/x86_64-linux-gnu/libstdc++.so.6 \
|
||||
&& python3 -c "from OCC.Core.STEPControl import STEPControl_Reader; print('pythonocc-core OK')"
|
||||
|
||||
# cadquery(与 Dockerfile.dev 一致)
|
||||
ARG PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple
|
||||
ARG PIP_DEFAULT_TIMEOUT=300
|
||||
COPY requirements-geometry.txt /tmp/requirements-geometry.txt
|
||||
RUN python3 -m pip install --no-cache-dir --break-system-packages \
|
||||
--default-timeout="${PIP_DEFAULT_TIMEOUT}" \
|
||||
--retries 10 \
|
||||
-i "${PIP_INDEX_URL}" \
|
||||
-r /tmp/requirements-geometry.txt \
|
||||
&& rm /tmp/requirements-geometry.txt \
|
||||
&& python3 -c "import cadquery; print('cadquery OK')"
|
||||
|
||||
# PyTorch CUDA 12.1:默认官方 CDN;覆盖示例:--build-arg TORCH_INDEX_URL=https://download.pytorch.org/whl/cu121
|
||||
ARG TORCH_INDEX_URL=https://download.pytorch.org/whl/cu121
|
||||
RUN python3 -m pip install --no-cache-dir --break-system-packages \
|
||||
--default-timeout=600 --retries 10 \
|
||||
torch==2.3.1 torchvision==0.18.1 \
|
||||
--index-url "${TORCH_INDEX_URL}"
|
||||
|
||||
# PyTorch3D 预编译轮仅 Meta 官方 CDN,无稳定国内镜像;加大超时。可本地下载 wheel 后 COPY + pip install。
|
||||
RUN python3 -m pip install --no-cache-dir --break-system-packages \
|
||||
--default-timeout=300 --retries 10 \
|
||||
-i https://pypi.tuna.tsinghua.edu.cn/simple \
|
||||
trimesh \
|
||||
&& python3 -m pip install --no-cache-dir --break-system-packages \
|
||||
--default-timeout=600 --retries 15 \
|
||||
pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/py310_cu121_pyt231/download.html
|
||||
|
||||
RUN python3 -c "import torch; import pytorch3d; import trimesh; print('pytorch', torch.__version__, 'pytorch3d', pytorch3d.__version__)"
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN corepack enable && corepack prepare pnpm@latest --activate
|
||||
|
||||
CMD ["node", "-e", "console.log('use docker-compose command')"]
|
||||
41
docker/env-config.md
Normal file
41
docker/env-config.md
Normal file
@@ -0,0 +1,41 @@
|
||||
# 环境变量配置说明
|
||||
|
||||
部署前,请在项目根目录创建 `.env` 文件,包含以下配置:
|
||||
|
||||
## 安全配置 (必须修改!)
|
||||
|
||||
```bash
|
||||
# JWT密钥 - 用于会话签名,请使用随机字符串
|
||||
# 生成方法: openssl rand -base64 32
|
||||
JWT_SECRET=your-super-secret-jwt-key-change-in-production
|
||||
|
||||
# MySQL root密码
|
||||
MYSQL_ROOT_PASSWORD=root_password_change_me
|
||||
```
|
||||
|
||||
## MinIO对象存储配置
|
||||
|
||||
```bash
|
||||
# MinIO管理员用户名
|
||||
MINIO_ROOT_USER=minioadmin
|
||||
|
||||
# MinIO管理员密码 (至少8个字符)
|
||||
MINIO_ROOT_PASSWORD=minioadmin123
|
||||
```
|
||||
|
||||
## 应用配置
|
||||
|
||||
```bash
|
||||
# 应用标题
|
||||
VITE_APP_TITLE=宏量点云处理系统
|
||||
```
|
||||
|
||||
## 可选配置
|
||||
|
||||
```bash
|
||||
# 启用Redis缓存 (需要在docker-compose中启用with-cache profile)
|
||||
# REDIS_URL=redis://redis:6379
|
||||
|
||||
# 日志级别: debug, info, warn, error
|
||||
# LOG_LEVEL=info
|
||||
```
|
||||
166
docker/mysql/init.sql
Normal file
166
docker/mysql/init.sql
Normal file
@@ -0,0 +1,166 @@
|
||||
-- 宏量点云处理软件 - 数据库初始化脚本
|
||||
-- 该脚本在MySQL容器首次启动时自动执行
|
||||
-- 后续增量迁移由 server/_core/index.ts runMigrations() 从 drizzle/*.sql 自动应用
|
||||
|
||||
-- 设置字符集
|
||||
SET NAMES utf8mb4;
|
||||
SET CHARACTER SET utf8mb4;
|
||||
|
||||
-- 确保数据库存在
|
||||
CREATE DATABASE IF NOT EXISTS pointcloud_db
|
||||
CHARACTER SET utf8mb4
|
||||
COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
USE pointcloud_db;
|
||||
|
||||
-- 用户表
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
openId VARCHAR(64) NOT NULL UNIQUE,
|
||||
name TEXT,
|
||||
email VARCHAR(320),
|
||||
loginMethod VARCHAR(64),
|
||||
role ENUM('user', 'admin') NOT NULL DEFAULT 'user',
|
||||
createdAt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updatedAt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
lastSignedIn TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
INDEX idx_openId (openId),
|
||||
INDEX idx_email (email(255))
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- 点云项目表(旧版,兼容保留)
|
||||
CREATE TABLE IF NOT EXISTS point_cloud_projects (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
userId INT NOT NULL,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
description TEXT,
|
||||
cadModelUrl TEXT,
|
||||
cadModelName VARCHAR(255),
|
||||
totalChunks INT NOT NULL DEFAULT 0,
|
||||
processedChunks INT NOT NULL DEFAULT 0,
|
||||
totalPoints BIGINT NOT NULL DEFAULT 0,
|
||||
status ENUM('pending', 'uploading', 'processing', 'completed', 'error') NOT NULL DEFAULT 'pending',
|
||||
createdAt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updatedAt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
INDEX idx_userId (userId),
|
||||
INDEX idx_status (status),
|
||||
FOREIGN KEY (userId) REFERENCES users(id) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- 点云数据块表(旧版,兼容保留)
|
||||
CREATE TABLE IF NOT EXISTS point_cloud_chunks (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
projectId INT NOT NULL,
|
||||
chunkIndex INT NOT NULL,
|
||||
fileName VARCHAR(255) NOT NULL,
|
||||
fileUrl TEXT NOT NULL,
|
||||
fileSize BIGINT NOT NULL DEFAULT 0,
|
||||
pointCount INT NOT NULL DEFAULT 0,
|
||||
status ENUM('pending', 'uploading', 'processing', 'completed', 'error') NOT NULL DEFAULT 'pending',
|
||||
lodLevel INT NOT NULL DEFAULT 0,
|
||||
boundingBox JSON,
|
||||
createdAt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updatedAt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
INDEX idx_projectId (projectId),
|
||||
INDEX idx_status (status),
|
||||
UNIQUE KEY uk_project_chunk (projectId, chunkIndex),
|
||||
FOREIGN KEY (projectId) REFERENCES point_cloud_projects(id) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- CAD模型表(旧版,兼容保留)
|
||||
CREATE TABLE IF NOT EXISTS cad_models (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
userId INT NOT NULL,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
format VARCHAR(32) NOT NULL,
|
||||
fileUrl TEXT NOT NULL,
|
||||
fileSize BIGINT NOT NULL DEFAULT 0,
|
||||
vertices INT NOT NULL DEFAULT 0,
|
||||
faces INT NOT NULL DEFAULT 0,
|
||||
boundingBox JSON,
|
||||
createdAt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
INDEX idx_userId (userId),
|
||||
FOREIGN KEY (userId) REFERENCES users(id) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- 分析结果表(旧版,兼容保留)
|
||||
CREATE TABLE IF NOT EXISTS analysis_results (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
projectId INT NOT NULL,
|
||||
analysisType ENUM('error', 'measurement', 'compression') NOT NULL,
|
||||
resultData JSON NOT NULL,
|
||||
createdAt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
INDEX idx_projectId (projectId),
|
||||
INDEX idx_type (analysisType),
|
||||
FOREIGN KEY (projectId) REFERENCES point_cloud_projects(id) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- ─── 车系/车型/检测任务/分析结果 层级结构 ──────────────────────────────────────
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `vehicle_series` (
|
||||
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||
`name` VARCHAR(100) NOT NULL,
|
||||
`description` TEXT,
|
||||
`createdAt` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`updatedAt` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `vehicle_models` (
|
||||
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||
`seriesId` INT NOT NULL,
|
||||
`name` VARCHAR(100) NOT NULL,
|
||||
`description` TEXT,
|
||||
`createdAt` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`updatedAt` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `model_cad_files` (
|
||||
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||
`modelId` INT NOT NULL,
|
||||
`name` VARCHAR(255) NOT NULL,
|
||||
`format` VARCHAR(32) NOT NULL,
|
||||
`fileSize` BIGINT NOT NULL,
|
||||
`filePath` VARCHAR(512) NOT NULL,
|
||||
`createdAt` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `inspection_tasks` (
|
||||
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||
`modelId` INT NOT NULL,
|
||||
`name` VARCHAR(255) NOT NULL,
|
||||
`inspector` VARCHAR(100),
|
||||
`notes` TEXT,
|
||||
`status` ENUM('pending','processing','completed','error') NOT NULL DEFAULT 'pending',
|
||||
`createdAt` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`updatedAt` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
`completedAt` TIMESTAMP NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `task_pointcloud_files` (
|
||||
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||
`taskId` INT NOT NULL,
|
||||
`name` VARCHAR(255) NOT NULL,
|
||||
`fileSize` BIGINT NOT NULL,
|
||||
`filePath` VARCHAR(512) NOT NULL,
|
||||
`createdAt` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `task_analysis_results` (
|
||||
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||
`taskId` INT NOT NULL,
|
||||
`type` ENUM('error_analysis','measurement','compression','smooth_heatmap','assembly_inspection','obj_deviation') NOT NULL,
|
||||
`status` ENUM('pending','processing','completed','error') NOT NULL DEFAULT 'pending',
|
||||
`errorStats` JSON,
|
||||
`measurements` JSON,
|
||||
`resultData` JSON,
|
||||
`createdAt` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`updatedAt` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- 创建默认管理员用户 (内网部署使用)
|
||||
INSERT INTO users (openId, name, email, role) VALUES
|
||||
('admin-local', '系统管理员', 'admin@localhost', 'admin')
|
||||
ON DUPLICATE KEY UPDATE name = VALUES(name);
|
||||
|
||||
-- 输出初始化完成信息
|
||||
SELECT 'Database initialization completed successfully!' AS message;
|
||||
152
docker/nginx/nginx.conf
Normal file
152
docker/nginx/nginx.conf
Normal file
@@ -0,0 +1,152 @@
|
||||
# 宏量点云处理软件 - Nginx反向代理配置
|
||||
# 适用于内网生产环境部署
|
||||
|
||||
user nginx;
|
||||
worker_processes auto;
|
||||
error_log /var/log/nginx/error.log warn;
|
||||
pid /var/run/nginx.pid;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
use epoll;
|
||||
multi_accept on;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
# 日志格式
|
||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
'$status $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent" "$http_x_forwarded_for" '
|
||||
'rt=$request_time uct="$upstream_connect_time" '
|
||||
'uht="$upstream_header_time" urt="$upstream_response_time"';
|
||||
|
||||
access_log /var/log/nginx/access.log main;
|
||||
|
||||
# 性能优化
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
keepalive_timeout 65;
|
||||
types_hash_max_size 2048;
|
||||
|
||||
# Gzip压缩
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_proxied any;
|
||||
gzip_comp_level 6;
|
||||
gzip_types text/plain text/css text/xml application/json application/javascript
|
||||
application/rss+xml application/atom+xml image/svg+xml;
|
||||
|
||||
# 文件上传大小限制 (支持大型点云文件)
|
||||
client_max_body_size 2G;
|
||||
client_body_buffer_size 128M;
|
||||
client_body_timeout 600s;
|
||||
|
||||
# 代理缓冲设置
|
||||
proxy_buffer_size 128k;
|
||||
proxy_buffers 4 256k;
|
||||
proxy_busy_buffers_size 256k;
|
||||
proxy_temp_file_write_size 256k;
|
||||
|
||||
# 上游服务器
|
||||
upstream app_server {
|
||||
server app:3000;
|
||||
keepalive 32;
|
||||
}
|
||||
|
||||
upstream minio_server {
|
||||
server minio:9000;
|
||||
keepalive 32;
|
||||
}
|
||||
|
||||
# HTTP服务器 (重定向到HTTPS,生产环境启用)
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
|
||||
# 如果启用HTTPS,取消下面的注释
|
||||
# return 301 https://$host$request_uri;
|
||||
|
||||
# 如果不使用HTTPS,使用下面的配置
|
||||
location / {
|
||||
proxy_pass http://app_server;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection 'upgrade';
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
proxy_read_timeout 600s;
|
||||
proxy_connect_timeout 600s;
|
||||
proxy_send_timeout 600s;
|
||||
}
|
||||
|
||||
# API路由
|
||||
location /api/ {
|
||||
proxy_pass http://app_server;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_read_timeout 600s;
|
||||
proxy_connect_timeout 600s;
|
||||
proxy_send_timeout 600s;
|
||||
}
|
||||
|
||||
# MinIO存储代理 (可选)
|
||||
location /storage/ {
|
||||
rewrite ^/storage/(.*) /$1 break;
|
||||
proxy_pass http://minio_server;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
|
||||
# 健康检查端点
|
||||
location /health {
|
||||
access_log off;
|
||||
return 200 "healthy\n";
|
||||
add_header Content-Type text/plain;
|
||||
}
|
||||
}
|
||||
|
||||
# HTTPS服务器 (生产环境启用,需要配置SSL证书)
|
||||
# server {
|
||||
# listen 443 ssl http2;
|
||||
# server_name your-domain.com;
|
||||
#
|
||||
# ssl_certificate /etc/nginx/ssl/cert.pem;
|
||||
# ssl_certificate_key /etc/nginx/ssl/key.pem;
|
||||
# ssl_session_timeout 1d;
|
||||
# ssl_session_cache shared:SSL:50m;
|
||||
# ssl_session_tickets off;
|
||||
#
|
||||
# ssl_protocols TLSv1.2 TLSv1.3;
|
||||
# ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256;
|
||||
# ssl_prefer_server_ciphers off;
|
||||
#
|
||||
# # HSTS
|
||||
# add_header Strict-Transport-Security "max-age=63072000" always;
|
||||
#
|
||||
# location / {
|
||||
# proxy_pass http://app_server;
|
||||
# proxy_http_version 1.1;
|
||||
# proxy_set_header Upgrade $http_upgrade;
|
||||
# proxy_set_header Connection 'upgrade';
|
||||
# proxy_set_header Host $host;
|
||||
# proxy_set_header X-Real-IP $remote_addr;
|
||||
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
# proxy_set_header X-Forwarded-Proto $scheme;
|
||||
# proxy_cache_bypass $http_upgrade;
|
||||
# proxy_read_timeout 600s;
|
||||
# }
|
||||
# }
|
||||
}
|
||||
Reference in New Issue
Block a user