Files

125 lines
3.6 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# anqicms 部署栈
[anqicms](https://github.com/anqicms/anqicms) 是一个轻量、SEO 友好的中文内容管理系统,面向博客、自媒体和中小型企业建站场景,基于 Go 开发,开箱即用。
## 目录结构
| 文件 | 说明 |
|------|------|
| `stack.yml` | Docker Compose 编排文件 |
| `env.cfg.example` | 环境变量模板(不含敏感信息,可提交) |
| `env.cfg` | **实际环境变量(gitignore,不提交)** — 部署时从 example 复制 |
| `readme.md` | 本文档 |
## 服务端口
| 宿主机 | 容器 | 说明 |
|--------|------|------|
| `${ANQICMS_PORT}`(默认 `8001` | `8001` | Web 服务(含前台 + 后台) |
宿主机端口可通过 `env.cfg` 中的 `ANQICMS_PORT` 自定义。
## 数据卷映射
| 容器路径 | 宿主机路径 | 说明 |
|----------|------------|------|
| `/app` | `${Volumes_Path}` | 应用数据根(配置、上传、缓存、主题、插件等) |
| `/etc/timezone` | `/etc/timezone` | 时区(只读) |
| `/etc/localtime` | `/etc/localtime` | 本地时间(只读) |
## 环境变量
### 公共变量(`env.cfg.example`
| 变量 | 默认值 | 说明 |
|------|--------|------|
| `IMAGE_TAG_VER` | `latest` | anqicms 镜像版本号 |
| `IMAGE_TAG` | `anqicms/anqicms:${IMAGE_TAG_VER}` | 完整镜像引用 |
| `Volumes_Path` | `/data/volumes/anqicms` | 宿主机持久化目录 |
| `ANQICMS_PORT` | `8001` | 宿主机端口 |
## 部署步骤
### 首次部署
```bash
# 1. 准备数据目录
mkdir -pv /data/volumes/anqicms
# 2. 复制 env 模板并按需修改
cp env.cfg.example env.cfg
$EDITOR env.cfg
# 3. 拉取镜像
docker compose -p anqicms --env-file ./anqicms/env.cfg -f ./anqicms/stack.yml pull
# 4. 启动服务
docker compose -p anqicms --env-file ./anqicms/env.cfg -f ./anqicms/stack.yml up -d
```
### 首次访问
容器启动后,浏览器访问 `http://<host-ip>:${ANQICMS_PORT}/`,按安装向导完成:
- 设置管理员账号 / 密码
- 选择数据库(默认 SQLite,零外部依赖;如需 MySQL 在向导里填连接信息)
- 完成初始化
### 验证
```bash
# 容器状态
docker ps -f name=anqicms
# 端口监听
ss -tlnp | grep ${ANQICMS_PORT}
# 容器日志
docker logs -f anqicms
# 健康检查
curl -sI http://localhost:${ANQICMS_PORT}/
```
### 停止 / 重启
```bash
# 停止(保留数据)
docker compose -p anqicms --env-file ./anqicms/env.cfg -f ./anqicms/stack.yml stop
# 完全销毁(**数据不删**,bind 挂载保留在宿主机)
docker compose -p anqicms --env-file ./anqicms/env.cfg -f ./anqicms/stack.yml down
# 重启
docker compose -p anqicms --env-file ./anqicms/env.cfg -f ./anqicms/stack.yml restart
```
## 升级
```bash
# 1. 备份数据(先停服)
docker compose -p anqicms --env-file ./anqicms/env.cfg -f ./anqicms/stack.yml stop
sudo rsync -a /data/volumes/anqicms/ /data/backups/anqicms/$(date +%Y%m%d)/
# 2. 修改 IMAGE_TAG_VER 后拉取
$EDITOR env.cfg
docker compose -p anqicms --env-file ./anqicms/env.cfg -f ./anqicms/stack.yml pull
# 3. 重建并启动
docker compose -p anqicms --env-file ./anqicms/env.cfg -f ./anqicms/stack.yml up -d
```
## 故障排查
| 症状 | 排查命令 |
|------|----------|
| 容器起不来 | `docker logs -f anqicms` |
| 端口冲突 | `ss -tlnp \| grep ${ANQICMS_PORT}` |
| 无法访问 | 检查防火墙/安全组、`curl -sI http://localhost:${ANQICMS_PORT}/` |
| 数据丢失 | 确认 bind 挂载路径正确,不要用 anonymous volume |
## 相关链接
- GitHub: <https://github.com/anqicms/anqicms>
- Docker Hub: <https://hub.docker.com/r/anqicms/anqicms>
- 文档: <https://www.anqicms.com/docs>