feat(docker): add Compose stack for MySQL, Redis and Nexus API
- Dockerfile with healthcheck and entrypoint for deps + .env persistence - generate_env.py for local secrets; design docs and changelog Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
# Nexus Docker
|
||||
|
||||
## 前置
|
||||
|
||||
- [Docker Desktop](https://www.docker.com/products/docker-desktop/)(Windows/macOS)或 Docker Engine + Compose v2
|
||||
|
||||
## 快速启动(正常模式)
|
||||
|
||||
```bash
|
||||
# 1. 生成密钥(写入 docker/.env,已 gitignore)
|
||||
python docker/generate_env.py
|
||||
|
||||
# 2. 构建并启动
|
||||
docker compose up -d --build
|
||||
|
||||
# 3. 健康检查
|
||||
curl -s http://localhost:8600/health # 期望: ok
|
||||
|
||||
# 4. 打开 SPA
|
||||
# http://localhost:8600/app/
|
||||
```
|
||||
|
||||
默认管理员需在安装向导或已有 DB 中配置;若 DB 为空且未跑过 install,可删卷后走安装模式。
|
||||
|
||||
## 安装向导模式
|
||||
|
||||
不创建 `docker/.env`(或清空 `NEXUS_SECRET_KEY`)时,应用以 **安装模式** 启动:
|
||||
|
||||
- http://localhost:8600/app/install.html
|
||||
|
||||
完成向导后 `.env` 会写入容器;`nexus-state` 卷会在重启时恢复配置。
|
||||
|
||||
## 常用命令
|
||||
|
||||
```bash
|
||||
docker compose logs -f nexus
|
||||
docker compose down # 停止,保留数据卷
|
||||
docker compose down -v # 停止并删除数据卷(清空 DB)
|
||||
docker compose build --no-cache nexus
|
||||
```
|
||||
|
||||
## 服务
|
||||
|
||||
| 服务 | 端口 | 说明 |
|
||||
|------|------|------|
|
||||
| nexus | 8600 | FastAPI + 静态 `/app/` |
|
||||
| mysql | 3306 | 数据库 `nexus` |
|
||||
| redis | 6379 | 仅容器内网(未映射到主机) |
|
||||
|
||||
## 生产注意
|
||||
|
||||
- 修改 `MYSQL_*` 与 `NEXUS_*` 为强密码,勿使用 `generate_env.py` 默认值上生产。
|
||||
- 建议前置 Nginx/TLS,仅暴露 443。
|
||||
- 多实例部署需共享 MySQL、Redis;后台任务由 Redis primary lock 保证单实例执行。
|
||||
|
||||
详见 `docs/design/specs/2026-06-03-docker-design.md`。
|
||||
Reference in New Issue
Block a user