docs(deploy): add Docker Compose deployment documentation
- Document compose.yaml configuration with image, restart policy, and port mapping details - Restructure audit log directory layout documentation - Add deployment config file notes for environment isolation
This commit is contained in:
@@ -247,7 +247,74 @@ docker run -d \
|
||||
|
||||
### Docker Compose
|
||||
|
||||
Compose 文件待补充。注意生产环境应执行 `bookmgr.schema.sql`(仅建表,不含种子数据),用户由应用初始化。
|
||||
### 部署配置文件说明
|
||||
|
||||
项目提供标准化 `compose\.yaml` 部署文件,支持一键启动、环境隔离、日志持久化,适配本地开发与测试环境,默认采用**手动管控模式**,服务器重启后不会自动拉起服务,需手动执行启动命令。
|
||||
|
||||
#### compose\.yaml 配置
|
||||
|
||||
```yaml
|
||||
services:
|
||||
bookmgr:
|
||||
image: git.msksbr.com/msksbr/bookmgr:latest
|
||||
container_name: bookmgr
|
||||
restart: unless-stopped # 官方标准策略:异常自动重启、默认开机自启,仅手动stop后重启机器不会自启
|
||||
|
||||
# 加载本地环境变量配置文件
|
||||
env_file:
|
||||
- .env
|
||||
|
||||
# 端口映射:主机8080映射容器8080端口
|
||||
ports:
|
||||
- "8080:8080"
|
||||
|
||||
# 日志目录持久化挂载,容器日志落地至宿主机
|
||||
volumes:
|
||||
- ./log:/var/log/bookmgr
|
||||
|
||||
# 本地MySQL专用网络穿透(宿主机数据库开启注释使用)
|
||||
# extra_hosts:
|
||||
# - host.docker.internal:host-gateway
|
||||
```
|
||||
|
||||
#### \.env 环境变量配置示例
|
||||
|
||||
统一管理数据库、日志等核心配置,无需修改 compose 文件,开箱即用:
|
||||
|
||||
```bash
|
||||
# ====================== 数据库核心配置 ======================
|
||||
# MySQL驱动类
|
||||
DB_DRIVER=com.mysql.cj.jdbc.Driver
|
||||
# 数据库类型
|
||||
DB_TYPE=mysql
|
||||
# 数据库连接地址
|
||||
# Docker容器访问本地MySQL请改为:host.docker.internal
|
||||
DB_URL=localhost
|
||||
# MySQL端口号
|
||||
DB_PORT=3306
|
||||
# 业务数据库名称
|
||||
DB_NAME=bookmgr
|
||||
# 数据库登录用户名
|
||||
DB_USER=root
|
||||
# 数据库登录密码
|
||||
DB_PASSWORD=password
|
||||
|
||||
# ====================== 日志配置 ======================
|
||||
# 容器内日志存储路径
|
||||
LOG_PATH=/var/log/bookmgr
|
||||
# 开启运行时日志导出,便于问题排查(推荐开启)
|
||||
LOG_EXPORT_RUNTIME=true
|
||||
```
|
||||
|
||||
### 关键使用说明
|
||||
|
||||
- **网络适配**:若 MySQL 部署在宿主机,需取消 `extra\_hosts` 注释,并将 `DB\_URL` 修改为 `host\.docker\.internal`,解决容器无法访问宿主机数据库问题。
|
||||
|
||||
- **运行模式**:`restart: no` 为手动测试专用模式,服务完全手动管控,关机/重启不会自启,适配黑盒测试场景。
|
||||
|
||||
- **日志持久化**:自动将容器运行日志挂载到宿主机 `\./log` 目录,永久留存,方便日志排查与数据分析。
|
||||
|
||||
- **版本更新**:搭配自研镜像构建脚本,`latest` 标签会自动同步最新构建版本,支持一键更新部署。
|
||||
|
||||
## 审计日志
|
||||
|
||||
|
||||
Reference in New Issue
Block a user