🎨 重构用户端前端为vue开发,完善基础类和角色相关接口
This commit is contained in:
42
deploy/postgres/Dockerfile
Normal file
42
deploy/postgres/Dockerfile
Normal file
@@ -0,0 +1,42 @@
|
||||
# ====================================================
|
||||
# 基于官方 PostgreSQL 18.1 镜像 + pgvector 扩展
|
||||
# ====================================================
|
||||
|
||||
FROM postgres:18.1
|
||||
|
||||
# 设置维护者信息
|
||||
LABEL maintainer="st-dev@example.com"
|
||||
LABEL description="PostgreSQL 18.1 with pgvector extension"
|
||||
|
||||
# 安装依赖
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
build-essential \
|
||||
git \
|
||||
postgresql-server-dev-18 \
|
||||
ca-certificates && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# 安装 pgvector 扩展
|
||||
RUN cd /tmp && \
|
||||
git clone --branch v0.7.4 https://github.com/pgvector/pgvector.git && \
|
||||
cd pgvector && \
|
||||
make && \
|
||||
make install && \
|
||||
cd / && \
|
||||
rm -rf /tmp/pgvector
|
||||
|
||||
# 清理
|
||||
RUN apt-get purge -y --auto-remove build-essential git postgresql-server-dev-18 && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# 设置时区
|
||||
ENV TZ=Asia/Shanghai
|
||||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||
|
||||
# 暴露端口
|
||||
EXPOSE 5432
|
||||
|
||||
# 使用默认的 PostgreSQL 入口点
|
||||
CMD ["postgres"]
|
||||
82
deploy/postgres/init.sql
Normal file
82
deploy/postgres/init.sql
Normal file
@@ -0,0 +1,82 @@
|
||||
-- ====================================================
|
||||
-- 云酒馆数据库初始化脚本
|
||||
-- ====================================================
|
||||
|
||||
-- 设置客户端编码
|
||||
SET client_encoding = 'UTF8';
|
||||
|
||||
-- 创建必要的扩展
|
||||
-- ====================================================
|
||||
|
||||
-- 1. pgvector - 向量相似度搜索扩展(用于 AI 记忆功能)
|
||||
CREATE EXTENSION IF NOT EXISTS vector;
|
||||
|
||||
-- 2. uuid-ossp - UUID 生成扩展(用于生成唯一标识符)
|
||||
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
|
||||
|
||||
-- 3. pg_trgm - 三元组模糊匹配扩展(用于全文搜索)
|
||||
CREATE EXTENSION IF NOT EXISTS pg_trgm;
|
||||
|
||||
-- 4. btree_gin - GIN 索引扩展(用于加速 JSONB 查询)
|
||||
CREATE EXTENSION IF NOT EXISTS btree_gin;
|
||||
|
||||
-- 验证扩展是否安装成功
|
||||
-- ====================================================
|
||||
DO $$
|
||||
BEGIN
|
||||
RAISE NOTICE '===========================================';
|
||||
RAISE NOTICE '云酒馆数据库初始化完成!';
|
||||
RAISE NOTICE '===========================================';
|
||||
RAISE NOTICE '已安装的扩展:';
|
||||
RAISE NOTICE ' ✓ vector - 向量相似度搜索';
|
||||
RAISE NOTICE ' ✓ uuid-ossp - UUID 生成';
|
||||
RAISE NOTICE ' ✓ pg_trgm - 模糊搜索';
|
||||
RAISE NOTICE ' ✓ btree_gin - GIN 索引优化';
|
||||
RAISE NOTICE '===========================================';
|
||||
RAISE NOTICE '数据库信息:';
|
||||
RAISE NOTICE ' 数据库名: st_dev';
|
||||
RAISE NOTICE ' 用户名: st_user';
|
||||
RAISE NOTICE ' 字符集: UTF8';
|
||||
RAISE NOTICE '===========================================';
|
||||
END $$;
|
||||
|
||||
-- 创建用户并授予权限
|
||||
-- ====================================================
|
||||
-- 如果需要额外的只读用户,可以取消以下注释
|
||||
-- CREATE USER st_readonly WITH PASSWORD 'readonly_password';
|
||||
-- GRANT CONNECT ON DATABASE st_dev TO st_readonly;
|
||||
-- GRANT USAGE ON SCHEMA public TO st_readonly;
|
||||
-- GRANT SELECT ON ALL TABLES IN SCHEMA public TO st_readonly;
|
||||
-- ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO st_readonly;
|
||||
|
||||
-- 性能优化设置
|
||||
-- ====================================================
|
||||
-- 启用 JIT 编译(PostgreSQL 11+)
|
||||
SET jit = on;
|
||||
|
||||
-- 设置默认的统计信息采样
|
||||
ALTER DATABASE st_dev SET default_statistics_target = 100;
|
||||
|
||||
-- 优化大数据量查询
|
||||
ALTER DATABASE st_dev SET work_mem = '16MB';
|
||||
|
||||
-- 提示信息
|
||||
-- ====================================================
|
||||
\echo ''
|
||||
\echo '=========================================='
|
||||
\echo '数据库初始化完成!'
|
||||
\echo '=========================================='
|
||||
\echo '连接信息:'
|
||||
\echo ' Host: localhost'
|
||||
\echo ' Port: 5432'
|
||||
\echo ' Database: st_dev'
|
||||
\echo ' Username: st_user'
|
||||
\echo ' Password: st_password'
|
||||
\echo '=========================================='
|
||||
\echo ''
|
||||
\echo '管理工具:'
|
||||
\echo ' pgAdmin: http://localhost:5050'
|
||||
\echo ' Email: admin@st.local'
|
||||
\echo ' Pass: admin123'
|
||||
\echo '=========================================='
|
||||
\echo ''
|
||||
79
deploy/postgres/postgresql.conf
Normal file
79
deploy/postgres/postgresql.conf
Normal file
@@ -0,0 +1,79 @@
|
||||
# ====================================================
|
||||
# PostgreSQL 配置文件(针对开发环境优化)
|
||||
# ====================================================
|
||||
|
||||
# 连接设置
|
||||
# ====================================================
|
||||
listen_addresses = '*'
|
||||
max_connections = 200
|
||||
superuser_reserved_connections = 3
|
||||
|
||||
# 内存设置
|
||||
# ====================================================
|
||||
shared_buffers = 256MB # 共享缓冲区(推荐系统内存的 25%)
|
||||
effective_cache_size = 1GB # 有效缓存大小(推荐系统内存的 50-75%)
|
||||
maintenance_work_mem = 128MB # 维护操作内存
|
||||
work_mem = 5MB # 排序和哈希表内存
|
||||
|
||||
# WAL(Write-Ahead Logging)设置
|
||||
# ====================================================
|
||||
wal_buffers = 16MB
|
||||
min_wal_size = 1GB
|
||||
max_wal_size = 4GB
|
||||
checkpoint_completion_target = 0.9
|
||||
|
||||
# 查询优化
|
||||
# ====================================================
|
||||
random_page_cost = 1.1 # SSD 优化(默认 4.0)
|
||||
effective_io_concurrency = 200 # SSD 优化(默认 1)
|
||||
default_statistics_target = 100
|
||||
|
||||
# 日志设置
|
||||
# ====================================================
|
||||
logging_collector = on
|
||||
log_destination = 'stderr'
|
||||
log_directory = 'log'
|
||||
log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'
|
||||
log_rotation_age = 1d
|
||||
log_rotation_size = 100MB
|
||||
log_line_prefix = '%m [%p] %u@%d '
|
||||
log_timezone = 'Asia/Shanghai'
|
||||
|
||||
# 慢查询日志
|
||||
log_min_duration_statement = 1000 # 记录超过 1 秒的查询
|
||||
log_statement = 'ddl' # 记录 DDL 语句
|
||||
|
||||
# 扩展配置
|
||||
# ====================================================
|
||||
shared_preload_libraries = 'vector' # 预加载 pgvector 扩展
|
||||
|
||||
# JIT 编译(提升性能)
|
||||
# ====================================================
|
||||
jit = on
|
||||
jit_above_cost = 100000
|
||||
jit_inline_above_cost = 500000
|
||||
jit_optimize_above_cost = 500000
|
||||
|
||||
# 时区设置
|
||||
# ====================================================
|
||||
timezone = 'Asia/Shanghai'
|
||||
|
||||
# 客户端连接默认设置
|
||||
# ====================================================
|
||||
client_encoding = 'UTF8'
|
||||
lc_messages = 'C'
|
||||
lc_monetary = 'C'
|
||||
lc_numeric = 'C'
|
||||
lc_time = 'C'
|
||||
|
||||
# 并行查询设置(提升大数据量查询性能)
|
||||
# ====================================================
|
||||
max_parallel_workers_per_gather = 2
|
||||
max_parallel_workers = 4
|
||||
max_worker_processes = 4
|
||||
|
||||
# 自动清理设置
|
||||
# ====================================================
|
||||
autovacuum = on
|
||||
autovacuum_max_workers = 3
|
||||
autovacuum_naptime = 1min
|
||||
Reference in New Issue
Block a user