优化更新
This commit is contained in:
@@ -57,7 +57,7 @@ cp .env.example .env
|
||||
# ============================================================
|
||||
DB_HOST=127.0.0.1 # 数据库主机地址(本地容器)
|
||||
DB_PORT=3306 # 数据库端口(MySQL 默认 3306)
|
||||
DB_DATABASE=djangoadmin.fastapi.elevue # 数据库名称
|
||||
DB_DATABASE=djangoadmin.fastapi.antdvue # 数据库名称
|
||||
DB_USERNAME=root # 数据库用户名
|
||||
DB_PASSWORD=your_password # 数据库密码(请修改为实际密码)
|
||||
|
||||
@@ -92,7 +92,7 @@ python -c "import secrets; print(secrets.token_urlsafe(48))"
|
||||
```yaml
|
||||
# +======================================================================
|
||||
# | 模块: Docker Compose 配置
|
||||
# | 说明: FastAPI+EleVue 应用服务容器编排
|
||||
# | 说明: FastAPI+AntdVue 应用服务容器编排
|
||||
# +======================================================================
|
||||
version: '3.7'
|
||||
# ============================================================
|
||||
@@ -102,11 +102,11 @@ services:
|
||||
# ------------------------------------------------------------
|
||||
# 后端服务
|
||||
# ------------------------------------------------------------
|
||||
fastapi_elevue:
|
||||
fastapi_antdvue:
|
||||
# 构建镜像名称
|
||||
image: fastapi_elevue
|
||||
image: fastapi_antdvue
|
||||
# 容器运行时名称
|
||||
container_name: fastapi_elevue
|
||||
container_name: fastapi_antdvue
|
||||
# 镜像构建配置
|
||||
build:
|
||||
context: ./ # 构建上下文路径(项目根目录)
|
||||
@@ -180,7 +180,7 @@ docker compose up -d
|
||||
[+] Building 45.2s (12/12) FINISHED
|
||||
[+] Running 2/2
|
||||
✔ Network djangoadmin_default Created
|
||||
✔ Container fastapi_elevue Started
|
||||
✔ Container fastapi_antdvue Started
|
||||
```
|
||||
|
||||
:::tip 访问服务
|
||||
@@ -214,7 +214,7 @@ docker compose logs -f
|
||||
docker compose logs --tail 100
|
||||
|
||||
# 查看指定服务日志
|
||||
docker compose logs -f fastapi_elevue
|
||||
docker compose logs -f fastapi_antdvue
|
||||
```
|
||||
|
||||
+ 停止与重启
|
||||
@@ -244,10 +244,10 @@ docker compose up --build
|
||||
|
||||
```bash
|
||||
# 进入运行中的容器终端
|
||||
docker compose exec fastapi_elevue bash
|
||||
docker compose exec fastapi_antdvue bash
|
||||
|
||||
# 在容器内执行 Python 命令
|
||||
docker compose exec fastapi_elevue python -c "print('hello')"
|
||||
docker compose exec fastapi_antdvue python -c "print('hello')"
|
||||
```
|
||||
|
||||
## 环境变量注入
|
||||
@@ -256,10 +256,10 @@ Docker 模式下,环境变量通过 `env_file` 从 `.env` 文件注入到容
|
||||
|
||||
```bash
|
||||
# 使用 --env-file 指定环境变量文件
|
||||
docker run --env-file .env fastapi_elevue
|
||||
docker run --env-file .env fastapi_antdvue
|
||||
|
||||
# 通过 -e 参数覆盖单个变量
|
||||
docker run -e FASTAPI_PORT=9090 fastapi_elevue
|
||||
docker run -e FASTAPI_PORT=9090 fastapi_antdvue
|
||||
```
|
||||
|
||||
:::tip 温馨提示
|
||||
@@ -314,7 +314,7 @@ ports:
|
||||
|
||||
```bash
|
||||
# 查看容器日志排查原因
|
||||
docker compose logs fastapi_elevue
|
||||
docker compose logs fastapi_antdvue
|
||||
```
|
||||
|
||||
常见原因:`JWT_SALT` 未配置、数据库连接失败、Redis 连接失败。
|
||||
|
||||
Reference in New Issue
Block a user