docs(readme): update CLI commands and docker syntax

Update all CLI command examples to use python -m module invocations for consistent virtual environment usage. Fix docker compose commands to use the hyphenated docker-compose syntax. Add missing directory navigation step to the quick start guide and refresh the command reference table.
This commit is contained in:
duanshuwen
2026-07-04 14:15:15 +08:00
parent 2a3615901c
commit 83906f481d

View File

@@ -27,7 +27,7 @@ Copy-Item .env.example .env
```powershell
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
python -m pip install -r requirements.txt
```
如果 PowerShell 阻止执行激活脚本,可临时允许当前进程执行脚本后再激活:
@@ -48,13 +48,13 @@ Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
启动本地 PostgreSQL 和 Redis
```powershell
docker compose up -d postgres redis
docker-compose up -d postgres redis
```
确认容器状态:
```powershell
docker compose ps
docker-compose ps
```
### 4. 初始化或升级数据库
@@ -62,7 +62,7 @@ docker compose ps
首次启动、迁移变更后执行:
```powershell
alembic upgrade head
python -m alembic upgrade head
```
空库首次导入初始化内容时执行:
@@ -82,7 +82,7 @@ python -m app.seed --no-reset
开发模式启动:
```powershell
uvicorn app.main:app --host 0.0.0.0 --port 4000 --reload
python -m uvicorn app.main:app --host 0.0.0.0 --port 4000 --reload
```
如果需要手动重启 4001 端口服务,先释放端口,再重新运行:
@@ -97,7 +97,7 @@ foreach ($listenerPid in $listenerPids) {
ForEach-Object { Stop-Process -Id $_.ProcessId -Force -ErrorAction SilentlyContinue }
Stop-Process -Id $listenerPid -Force -ErrorAction SilentlyContinue
}
uvicorn app.main:app --host 0.0.0.0 --port 4001 --reload
python -m uvicorn app.main:app --host 0.0.0.0 --port 4001 --reload
```
启动后访问:
@@ -108,12 +108,14 @@ uvicorn app.main:app --host 0.0.0.0 --port 4001 --reload
### 日常启动速查
数据库已经初始化后,通常只需要:
`D:\www\znkj\WonderQ-Project` 根目录手动启动时,先确认 Docker Desktop 已运行,通常只需要:
```powershell
Set-Location .\WonderQ-Admin
.\.venv\Scripts\Activate.ps1
docker compose up -d postgres redis
uvicorn app.main:app --host 0.0.0.0 --port 4000 --reload
docker-compose up -d postgres redis
python -m alembic upgrade head
python -m uvicorn app.main:app --host 0.0.0.0 --port 4001 --reload
```
## Docker 部署
@@ -121,7 +123,7 @@ uvicorn app.main:app --host 0.0.0.0 --port 4000 --reload
完整本地部署:
```bash
docker compose up --build
docker-compose up --build
```
服务包含:
@@ -139,7 +141,7 @@ alembic stamp head
空库或全新环境使用:
```bash
alembic upgrade head
python -m alembic upgrade head
python -m app.seed
```
@@ -156,15 +158,15 @@ python -m app.seed
## 常用命令
| 命令 | 说明 |
| ------------------------------------------- | --------------------------------- |
| `uvicorn app.main:app --reload --port 4000` | 启动开发服务 |
| `alembic upgrade head` | 创建或升级数据库结构 |
| `alembic stamp head` | 标记已有数据库已处于当前 baseline |
| `python -m app.seed` | 重置并导入初始化内容 |
| `python -m app.seed --no-reset` | 只确保默认后台账号存在 |
| `pytest` | 运行测试 |
| `docker compose up --build` | 构建并启动完整服务 |
| 命令 | 说明 |
| ----------------------------------------------------- | --------------------------------- |
| `python -m uvicorn app.main:app --reload --port 4000` | 启动开发服务 |
| `python -m alembic upgrade head` | 创建或升级数据库结构 |
| `alembic stamp head` | 标记已有数据库已处于当前 baseline |
| `python -m app.seed` | 重置并导入初始化内容 |
| `python -m app.seed --no-reset` | 只确保默认后台账号存在 |
| `python -m pytest` | 运行测试 |
| `docker-compose up --build` | 构建并启动完整服务 |
## API 兼容范围