Files
DjangoAdmin_FastAPI_NaiveVue/docker-compose.yml
T
2026-09-12 18:24:41 +08:00

44 lines
1.4 KiB
YAML

# +======================================================================
# | 模块: Docker Compose 配置
# | 说明: FastAPI+NaiveVue 应用服务容器编排
# +======================================================================
version: '3.7'
# ============================================================
# 应用服务
# ============================================================
services:
# 后端服务
fastapi_naivevue:
# 镜像名称
image: fastapi_naivevue
# 容器名称
container_name: fastapi_naivevue
# 构建镜像
build:
context: ./
dockerfile: Dockerfile
# 启动策略:始终重启
restart: always
# 网络模式:host 模式(DB_HOST/REDIS_HOST 为 127.0.0.1 时可直接连通宿主机)
# 注意:host 模式下 ports 映射会被忽略;若改为 bridge 网络,
# 需将 DB_HOST/REDIS_HOST 指向宿主机(如 host.docker.internal)并启用端口映射
network_mode: host
# 端口映射(仅在 bridge 网络模式下生效)
ports:
- 8031:8031
# 文件挂载
volumes:
- ./uploads:/data/apps/uploads
# 环境变量注入:从宿主机 .env 读取并注入容器进程
env_file:
- .env
# 执行命令
command: python src/main.py
# 日志配置
logging:
driver: "json-file"
options:
max-size: "500m"
max-file: "10"