forked from DevOps/deploy.stack
feat(anqicms): 添加 anqicms 部署文件
This commit is contained in:
@@ -0,0 +1,24 @@
|
|||||||
|
# ============================================================
|
||||||
|
# anqicms 部署 — 公共环境变量模板
|
||||||
|
# 复制为 env.cfg 后填入真实值,env.cfg 已在 .gitignore 中忽略
|
||||||
|
# ============================================================
|
||||||
|
#
|
||||||
|
# 使用方式:
|
||||||
|
# cp env.cfg.example env.cfg
|
||||||
|
# $EDITOR env.cfg # 按需修改端口和镜像版本
|
||||||
|
# docker compose -p anqicms --env-file ./env.cfg -f ./stack.yml up -d
|
||||||
|
|
||||||
|
# ---------- 镜像 ----------
|
||||||
|
# anqicms 版本号
|
||||||
|
IMAGE_TAG_VER=latest
|
||||||
|
# 完整镜像引用(默认 Docker Hub 官方镜像)
|
||||||
|
IMAGE_TAG=anqicms/anqicms:${IMAGE_TAG_VER}
|
||||||
|
|
||||||
|
# ---------- 数据卷 ----------
|
||||||
|
# 宿主机持久化目录(存放应用配置、上传文件、缓存、主题、插件等)
|
||||||
|
# 部署前手动创建:mkdir -pv /data/volumes/anqicms
|
||||||
|
Volumes_Path=/data/volumes/anqicms
|
||||||
|
|
||||||
|
# ---------- 服务端口 ----------
|
||||||
|
# 宿主机端口(容器内固定 8001)
|
||||||
|
ANQICMS_PORT=8001
|
||||||
@@ -0,0 +1,125 @@
|
|||||||
|
# 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>
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
# path:: mkdir -pv /data/volumes/anqicms
|
||||||
|
# pull:: docker compose -p anqicms --env-file ./anqicms/env.cfg -f ./anqicms/stack.yml pull
|
||||||
|
# run:: docker compose -p anqicms --env-file ./anqicms/env.cfg -f ./anqicms/stack.yml up -d
|
||||||
|
# disc::
|
||||||
|
# - /app 是容器内应用数据根目录(配置、上传、缓存、主题、插件等)
|
||||||
|
# - bind 挂载到 ${Volumes_Path} 实现持久化
|
||||||
|
# - 首次启动后通过 http://<host>:8001 进入安装向导
|
||||||
|
|
||||||
|
services:
|
||||||
|
anqicms:
|
||||||
|
image: ${IMAGE_TAG}
|
||||||
|
container_name: anqicms
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
- TZ=Asia/Shanghai
|
||||||
|
ports:
|
||||||
|
- "${ANQICMS_PORT}:8001"
|
||||||
|
volumes:
|
||||||
|
- ${Volumes_Path}:/app
|
||||||
|
- /etc/timezone:/etc/timezone:ro
|
||||||
|
- /etc/localtime:/etc/localtime:ro
|
||||||
Reference in New Issue
Block a user