Appearance
数据库服务
PasswordReset 部分服务(如监控面板、授权管理)依赖外部数据库。项目提供开箱即用的 Docker Compose 配置。
PostgreSQL(推荐)
Docker Compose
bash
docker compose -f docker-compose/DB/postgres.yml up -dyaml
# docker-compose/DB/postgres.yml
# =============================================================================
# PostgreSQL 数据库服务
# 访问端口: 5432
# 用途: 为 License / Monitor 服务提供 PostgreSQL 数据库
# 使用方式:
# docker compose -f docker-compose/DB/postgres.yml up -d
# 环境变量:
# PG_USER 数据库用户(默认: passwordreset)
# PG_PASS 数据库密码(默认: passwordreset)
# PG_DB 默认数据库(默认: passwordreset)
# =============================================================================
services:
postgres: # PostgreSQL 数据库
image: postgres:18-alpine # 镜像版本
container_name: passwordreset-postgres # 容器名称
environment:
POSTGRES_USER: ${PG_USER:-passwordreset} # 数据库用户
POSTGRES_PASSWORD: ${PG_PASS:-passwordreset} # 数据库密码
POSTGRES_DB: ${PG_DB:-passwordreset} # 默认数据库
ports:
- "5432:5432" # PostgreSQL 默认端口
volumes:
- ./db/postgres:/var/lib/postgresql/data # 数据持久化
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${PG_USER:-passwordreset}"]
interval: 5s # 健康检查间隔
timeout: 5s # 检查超时
retries: 5 # 重试次数
restart: unless-stopped # 容器退出策略bash
# docker-compose/DB/env.postgres.sh
# ===========================================
# PostgreSQL 数据库服务 - 环境变量配置
# ===========================================
# 数据库用户(默认: passwordreset)
PG_USER="passwordreset"
# 数据库密码(默认: passwordreset)
PG_PASS="passwordreset"
# 默认数据库(默认: passwordreset)
PG_DB="passwordreset"手动创建
sql
CREATE DATABASE your_service_name;
CREATE USER passwordreset WITH PASSWORD 'passwordreset';
GRANT ALL PRIVILEGES ON DATABASE your_service_name TO passwordreset;MySQL / MariaDB
Docker Compose
bash
docker compose -f docker-compose/DB/mysql.yml up -dyaml
# docker-compose/DB/mysql.yml
# =============================================================================
# MySQL 数据库服务
# 访问端口: 3306
# 用途: 为 License / Monitor 服务提供 MySQL 数据库
# 使用方式:
# docker compose -f docker-compose/DB/mysql.yml up -d
# 环境变量:
# MYSQL_ROOT_PASSWORD root 密码(默认: passwordreset)
# MYSQL_USER 普通用户(默认: passwordreset)
# MYSQL_PASSWORD 普通用户密码(默认: passwordreset)
# =============================================================================
services:
mysql: # MySQL 数据库
image: mysql:8 # 镜像版本
container_name: passwordreset-mysql # 容器名称
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASS:-passwordreset} # root 密码
MYSQL_USER: ${MYSQL_USER:-passwordreset} # 普通用户
MYSQL_PASSWORD: ${MYSQL_PASS:-passwordreset} # 普通用户密码
ports:
- "3306:3306" # MySQL 默认端口
volumes:
- ./db/mysql:/var/lib/mysql # 数据持久化
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
interval: 5s # 健康检查间隔
timeout: 5s # 检查超时
retries: 5 # 重试次数
restart: unless-stopped # 容器退出策略bash
# docker-compose/DB/env.mysql.sh
# ===========================================
# MySQL 数据库服务 - 环境变量配置
# ===========================================
# root 密码(默认: passwordreset)
MYSQL_ROOT_PASS="passwordreset"
# 普通用户(默认: passwordreset)
MYSQL_USER="passwordreset"
# 普通用户密码(默认: passwordreset)
MYSQL_PASS="passwordreset"手动创建
sql
CREATE DATABASE your_service_name CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'passwordreset'@'%' IDENTIFIED BY 'passwordreset';
GRANT ALL PRIVILEGES ON your_service_name.* TO 'passwordreset'@'%';
FLUSH PRIVILEGES;SQLite
无需外部数据库。各服务设置 DB_TYPE=sqlite 后自动在数据目录生成 .db 文件。