Skip to content

Commit dca739f

Browse files
committed
docs: enhance Docker configuration documentation and clarify environment variable usag
1 parent 7a1e38b commit dca739f

5 files changed

Lines changed: 77 additions & 0 deletions

File tree

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,24 @@ If omitted, local development defaults to `localhost:8080`; same-origin deployme
111111

112112
Priority: `environment variables > config.yaml > built-in defaults`.
113113

114+
The Docker image runs from `/app`. With the default compose mount below, the backend reads `/app/config.yaml` automatically:
115+
116+
```yaml
117+
volumes:
118+
- ./config.yaml:/app/config.yaml:ro
119+
```
120+
121+
To use a different file path, set `CONFIG_FILE` to the container path:
122+
123+
```yaml
124+
environment:
125+
CONFIG_FILE: "/app/config.yaml"
126+
```
127+
128+
Custom config file paths are read from `CONFIG_FILE`. If both compose environment variables and `config.yaml` define the same key, the environment variable wins. In `docker-compose.full.yml`, `POSTGRES_DSN`, `REDIS_ADDR`, and `REDIS_PASSWORD` are set in `environment`, so they override the PostgreSQL and Redis values in `config.yaml`.
129+
130+
`config.yaml` is for static infrastructure and security configuration such as server URLs, database, Redis, storage, GeoIP, tracing, JWT, and encryption keys. Runtime business settings are stored in the database and managed in the admin console, so changing those values in YAML after startup is not the source of truth.
131+
114132
`APP_ENV` accepts `dev`/`development` and `prod`/`production`, normalizes them to `dev` or `prod`, and defaults to `prod` when omitted. Use `dev` only for local development. Public production deployments should keep `APP_ENV=prod` or `APP_ENV=production` and use production secrets.
115133

116134
#### Lightweight Start
@@ -123,6 +141,8 @@ cp config.docker.example.yaml config.yaml
123141
docker compose up -d
124142
```
125143

144+
This mode primarily uses `config.yaml`; keep compose `environment` empty unless you intentionally want an environment variable to override the file.
145+
126146
#### Full Stack Start
127147

128148
Starts `app`, `postgres`, and `redis`. Use this for local evaluation, development smoke tests, or single-machine deployments without external services.
@@ -132,6 +152,8 @@ cp config.docker.example.yaml config.yaml
132152
docker compose -f docker-compose.full.yml up -d
133153
```
134154

155+
This mode uses compose environment variables for the bundled PostgreSQL and Redis services. Edit `docker-compose.full.yml` or remove those environment entries if you want `config.yaml` to provide these connection values instead.
156+
135157
The default application image is `ghcr.io/deeix-ai/deeix-chat:latest`. Override it with `DEEIX_CHAT_IMAGE` when testing a custom build:
136158

137159
```bash
@@ -140,6 +162,13 @@ DEEIX_CHAT_IMAGE=deeix-chat:local docker compose up -d --build
140162

141163
Docker URL: `http://localhost:8080`. Keep the Docker `server` section unchanged unless changing ports or public domains; then update compose ports, public URLs, and CORS together.
142164

165+
For troubleshooting, inspect startup logs and verify that the mounted file exists inside the container:
166+
167+
```bash
168+
docker compose exec app ls -l /app/config.yaml
169+
docker compose logs app
170+
```
171+
143172
#### Separated Deployment
144173

145174
Use this mode when the frontend and backend are served from different public origins, for example `https://chat.example.com` and `https://api.example.com`.
@@ -221,6 +250,8 @@ pnpm build
221250

222251
Static infrastructure configuration is loaded from the repository-level `config.yaml` and can be overridden by environment variables. Runtime business settings are stored in `system_settings` and managed from the admin console.
223252

253+
Docker deployments read `/app/config.yaml` by default when `./config.yaml` is mounted to `/app/config.yaml`. `CONFIG_FILE` can point to another container path.
254+
224255
Frontend build-time variables:
225256

226257
| Variable | Purpose |
@@ -232,6 +263,7 @@ Common backend environment variables:
232263
| Variable | Purpose |
233264
| --- | --- |
234265
| `APP_ENV` | Runtime environment. Accepts `dev`/`development` and `prod`/`production`; omitted values default to `prod`. |
266+
| `CONFIG_FILE` | Optional custom config file path inside the running process or container. Docker defaults to `/app/config.yaml` through the working directory and compose mount. |
235267
| `HTTP_PORT` | API/runtime port. |
236268
| `JWT_SECRET` | JWT signing secret. Must be strong in production. |
237269
| `DATA_ENCRYPTION_KEY` | Key material for encrypted secrets such as upstream API keys, SSO client secrets, MCP tokens, and TOTP secrets. |

README.zh-CN.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,24 @@ NEXT_PUBLIC_API_BASE_URL=http://127.0.0.1:8080
111111

112112
优先级:`环境变量 > config.yaml > 代码内置默认值`
113113

114+
Docker 镜像工作目录是 `/app`。使用默认 compose 挂载时,后端会自动读取 `/app/config.yaml`
115+
116+
```yaml
117+
volumes:
118+
- ./config.yaml:/app/config.yaml:ro
119+
```
120+
121+
如果需要指定其他配置文件路径,使用 `CONFIG_FILE`,值必须是容器内路径:
122+
123+
```yaml
124+
environment:
125+
CONFIG_FILE: "/app/config.yaml"
126+
```
127+
128+
自定义配置文件路径只读取 `CONFIG_FILE`。如果 compose 的 `environment` 和 `config.yaml` 同时配置同一个键,环境变量优先。`docker-compose.full.yml` 默认在 `environment` 中写入了 `POSTGRES_DSN`、`REDIS_ADDR`、`REDIS_PASSWORD`,因此会覆盖 `config.yaml` 中的 PostgreSQL 和 Redis 配置。
129+
130+
`config.yaml` 只负责静态基础设施和安全配置,例如服务地址、数据库、Redis、存储、GeoIP、Trace、JWT 和加密密钥。运行时业务配置存储在数据库中,并通过后台管理修改;这些配置启动后不以 YAML 为准。
131+
114132
`APP_ENV` 支持 `dev`/`development` 和 `prod`/`production`,内部会规范化为 `dev` 或 `prod`;未配置时默认 `prod`。`dev` 只用于本地开发;公网生产部署应保持 `APP_ENV=prod` 或 `APP_ENV=production` 并使用生产密钥。
115133

116134
#### 轻量启动
@@ -123,6 +141,8 @@ cp config.docker.example.yaml config.yaml
123141
docker compose up -d
124142
```
125143

144+
这种方式主要使用 `config.yaml`。除非明确希望用环境变量覆盖配置文件,否则 compose 中不需要额外写同名 `environment`。
145+
126146
#### 全量启动
127147

128148
启动 `app`、`postgres`、`redis` 三个容器。适合本机试用、开发自测或无外部数据库的单机部署。
@@ -132,6 +152,8 @@ cp config.docker.example.yaml config.yaml
132152
docker compose -f docker-compose.full.yml up -d
133153
```
134154

155+
这种方式会通过 compose 环境变量连接内置 PostgreSQL 和 Redis。如果希望这些连接配置完全来自 `config.yaml`,需要修改 `docker-compose.full.yml` 或删除对应 `environment` 项。
156+
135157
默认应用镜像为 `ghcr.io/deeix-ai/deeix-chat:latest`。测试自定义构建时可通过 `DEEIX_CHAT_IMAGE` 覆盖:
136158

137159
```bash
@@ -140,6 +162,13 @@ DEEIX_CHAT_IMAGE=deeix-chat:local docker compose up -d --build
140162

141163
Docker 地址:`http://localhost:8080`。除非修改端口或公网域名,否则不要改 Docker 配置里的 `server` 段;如需修改,端口映射、公开 URL 和 CORS 必须一起调整。
142164

165+
排查配置是否挂载成功时,可检查容器内文件和启动日志:
166+
167+
```bash
168+
docker compose exec app ls -l /app/config.yaml
169+
docker compose logs app
170+
```
171+
143172
#### 分离部署
144173

145174
当前端和后端分别暴露在不同公网地址时使用分离部署,例如 `https://chat.example.com` 和 `https://api.example.com`。
@@ -221,6 +250,8 @@ pnpm build
221250

222251
静态基础设施配置从仓库根目录的 `config.yaml` 读取,并支持环境变量覆盖。运行时业务配置存储在 `system_settings`,由后台管理。
223252

253+
Docker 部署默认通过 `./config.yaml:/app/config.yaml:ro` 挂载并读取 `/app/config.yaml`。如需自定义路径,使用 `CONFIG_FILE` 指向容器内路径。
254+
224255
前端构建期变量:
225256

226257
| 变量 | 作用 |
@@ -232,6 +263,7 @@ pnpm build
232263
| 变量 | 作用 |
233264
| --- | --- |
234265
| `APP_ENV` | 运行环境。支持 `dev`/`development` 和 `prod`/`production`;未配置时默认 `prod`。 |
266+
| `CONFIG_FILE` | 可选的配置文件路径,Docker 场景应填写容器内路径;默认 compose 挂载后会读取 `/app/config.yaml`。 |
235267
| `HTTP_PORT` | API/运行时端口。 |
236268
| `JWT_SECRET` | JWT 签名密钥,生产环境必须使用强随机值。 |
237269
| `DATA_ENCRYPTION_KEY` | 上游 API Key、SSO Client Secret、MCP Token、敏感设置和 TOTP Secret 的加密密钥材料。 |

config.docker.example.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ app:
33
# REQUIRED for deployment: change to prod and replace security/admin defaults below.
44
env: dev
55

6+
# Docker config loading notes:
7+
# - The image runs from /app and the compose files mount ./config.yaml to /app/config.yaml.
8+
# - /app/config.yaml is read automatically. Set CONFIG_FILE only for a different container path.
9+
# - Effective priority is environment variables > config.yaml > built-in defaults.
10+
# - docker-compose.full.yml sets POSTGRES_DSN, REDIS_ADDR, and REDIS_PASSWORD in environment,
11+
# so those values override the database.postgres/database.redis settings below.
12+
# - Runtime business settings are stored in the database and managed from the admin console.
13+
614
server:
715
# Docker defaults. Keep these values unless you are changing the exposed port or public domain.
816
# If http_port changes, also update the compose port mapping "<host_port>:<container_port>".

docker-compose.full.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ services:
1212
- redis
1313
environment:
1414
# Deployment topology: full compose connects to services on the compose network.
15+
# These environment variables override database.redis/database.postgres values in config.yaml.
1516
POSTGRES_DSN: "postgres://deeix_chat:deeix_chat_2026@postgres:5432/deeix_chat?sslmode=disable&TimeZone=Asia%2FShanghai"
1617
REDIS_ADDR: "redis:6379"
1718
REDIS_PASSWORD: "deeix_chat_2026"
@@ -20,6 +21,8 @@ services:
2021
- "127.0.0.1:8080:8080"
2122
volumes:
2223
- app_storage:/app/storage
24+
# The image runs from /app, so this file is loaded automatically as /app/config.yaml.
25+
# Set CONFIG_FILE only when mounting a different container path.
2326
- ./config.yaml:/app/config.yaml:ro
2427
networks:
2528
- deeix-chat

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ services:
1111
- "127.0.0.1:8080:8080"
1212
volumes:
1313
- app_storage:/app/storage
14+
# The image runs from /app, so this file is loaded automatically as /app/config.yaml.
15+
# Set CONFIG_FILE only when mounting a different container path.
1416
- ./config.yaml:/app/config.yaml:ro
1517
extra_hosts:
1618
- "host.docker.internal:host-gateway"

0 commit comments

Comments
 (0)