Appearance
Day-1 部署快速上手 / Day-1 Deployment Quickstart
⚠️ 先选对路径 / Pick the right path first
要用 Docker Compose 部署(绝大多数人)→ 不要看本文,直接:
bashcd deploy && bash install.sh先按
deploy/README.md客户配置表准备五个互不相同的纯域名:API_DOMAIN、ADMIN_DOMAIN、CS_WIDGET_DOMAIN、RTC_DOMAIN、TURN_DOMAIN,以及CERTBOT_EMAIL。 另需填写 API origin(IMBOY_BASE_URL)与独立清理数据库账号;该 LOGIN 须另行开通,密码须与数据库一致。.env不存在时首跑在依赖检查后只复制模板并退出;填写后重跑才补齐内部随机密钥与 RSA 密钥对并继续部署。 TLS 证书在五域 DNS、公共 TCP 80 的 HTTP-01 验证等条件满足后申请,不能视为离线自动生成。本文是裸机 / release 包部署路径:变量名带
IMBOY_前缀、密钥路径形如/etc/imboy/keys/,与 compose 路径的.env字段名和挂载点不通用,照抄会配错。If you deploy with Docker Compose (most people), use
deploy/install.shinstead — prepare five distinct bare hostnames, the certificate email and the additional customer inputs. The first run with no.envchecks dependencies and copies the template; the next run initializes internal secrets and deploys. TLS issuance requires working public DNS and HTTP-01 reachability. This document covers the bare-metal / release-package path; its variables are not interchangeable withdeploy/.env.
简体中文 / English — bilingual 适用版本 / Applies to: imboy v1.0.0-rc.1+ 目标 / Goal: 5 分钟内跑通生产部署的最小可用配置 / Stand up a minimal production deployment in 5 minutes. 完整参考手册 / Full manual: deployment.md | 自动化脚本 / Script: deploy-script.md
设计原则 / Design Principles
中文:
- 真相源唯一 — 所有运行时配置只有 3 个来源:
config/sys.config— 业务参数与端口默认值(Section A/B)IMBOY_*环境变量 — 部署期密钥与连接信息(Section C)IMBOYENV环境变量 — 运行环境标识(local / dev / prod)
- 生产 fail-fast — 缺密钥就拒绝启动,不存在「上线后才发现没设」。
- 辅助 PostgreSQL 容器 — 仓库根目录
docker-compose.yml按服务显式启动所需 PG(dev / pro);默认开发栈含 Garage、Nginx 等,不是deploy/的生产整栈安装;TURN 部署见 livekit-single-service-runbook.md。
English:
- Single source of truth — runtime config has only 3 inputs:
config/sys.config— business tunables & port defaults (Section A/B)IMBOY_*env vars — deploy-time secrets and connection info (Section C)IMBOYENVenv var — runtime tag (local / dev / prod)
- Fail-fast in prod — missing secrets refuse to boot; never discover after go-live.
- Supporting PostgreSQL containers — explicitly select the dev/pro PostgreSQL service in the repository-root
docker-compose.yml; the local stack also provides Garage and Nginx and is separate from the production installer underdeploy/. For TURN, see the LiveKit runbook.
1. 准备 .env / Prepare .env
中文:根级 .env.example 已定位为本地开发,不是裸机生产配置模板。裸机 release 应独立准备下文所需的真实运行时变量和密钥(已有 .env 不得覆盖),并按所用 release 或原生交付手册核对;不要直接复用本地 URL、密钥或 IMBOYENV=local。Compose 一键安装使用独立的 deploy/.env.example。
English: The root .env.example is local-development only. Prepare native release runtime variables and keys independently according to the deployed release and its native instructions; do not reuse local URLs, keys or IMBOYENV=local. The Compose installer uses deploy/.env.example.
bash
umask 077
# 编辑已有或专门准备的裸机运行时配置;不要覆盖既有 .env
${EDITOR:-vi} .env2. 必填环境变量 / Required environment variables
| 变量 / Variable | 说明 / Purpose | 生成方式 / Generate |
|---|---|---|
IMBOYENV | 运行环境 / Runtime tag | prod |
IMBOY_JWT_KEY | JWT 签名密钥 (32B) / JWT signing key | openssl rand -base64 32 |
IMBOY_POSTGRE_AES_KEY | PG 字段 AES 密钥 (32B) / PG field AES key | openssl rand -base64 32 |
IMBOY_ADM_COOKIE_SECRET | 管理后台 Cookie 签名密钥 / Admin cookie signing | openssl rand -hex 32 |
IMBOY_SOLIDIFIED_KEY | 客户端 init 加密密钥 (32B ASCII) / Client init AES key | openssl rand -hex 16 |
IMBOY_SOLIDIFIED_KEY_IV | 客户端 init AES IV (16B ASCII) / Client init AES IV | openssl rand -hex 8 |
IMBOY_PASSWORD_SALT | 旧密码 MD5 盐 (投产后不可改) / Legacy password salt (immutable after go-live) | openssl rand -hex 16 |
IMBOY_LOGIN_RSA_PUB_KEY_FILE | RSA 公钥 PEM 路径 / RSA pub key PEM path | /etc/imboy/keys/login_rsa_pub.pem |
IMBOY_LOGIN_RSA_PRIV_KEY_FILE | RSA 私钥 PEM 路径 / RSA priv key PEM path | /etc/imboy/keys/login_rsa_priv.pem |
IMBOY_PG_HOST | 数据库主机 / DB host | 127.0.0.1 |
IMBOY_PG_PORT | 数据库端口 / DB port | 5432 |
IMBOY_PG_DATABASE | 数据库名 / DB name | imboy_v1 |
IMBOY_PG_USERNAME | 数据库用户 / DB user | imboy_user |
IMBOY_PG_PASSWORD | 数据库密码 / DB password | (强密码 / strong) |
IMBOY_API_AUTH_SWITCH | API 签名验证开关 / API sig verify switch | on |
中文:以上任一缺失,
make rel跑出来的imboy启动会立刻error({missing_required_config, ...}),不会带病上线。 English: If any of the above is missing, the release built bymake relwill immediately raiseerror({missing_required_config, ...})on boot — never goes live in a broken state.
3. 条件必填 / Conditionally required
| 触发条件 / Trigger | 必填变量 / Required when triggered |
|---|---|
| 生产环境启用 LiveKit 通话(compose 部署已内置) | LIVEKIT_API_KEY、LIVEKIT_API_SECRET(secret ≥32 字符;deploy/install.sh 自动生成) |
push.enabled = true (sys.config) | IMBOY_JPUSH_APP_KEY, IMBOY_JPUSH_MASTER_SECRET |
sms.switch = <<"on">> & platform = <<"yjsms">> | IMBOY_YJSMS_ACCOUNT, IMBOY_YJSMS_SECRET |
sms.switch = <<"on">> & platform = <<"aliyun">> | sys.config 中 aliyun.key_id / key_secret 不可为空 |
中文:旧版此处的
eturnal_turn_urls/IMBOY_ETURNAL_SECRET条目已删除 —— eturnal 凭证链 已随 LiveKit 单服务迁移整体移除,TURN 由 LiveKit embedded TURN 承载 (详见 livekit-single-service-runbook.md)。
4. 生成 RSA 密钥 / Generate RSA keys
bash
sudo mkdir -p /etc/imboy/keys
sudo openssl genrsa -out /etc/imboy/keys/login_rsa_priv.pem 2048
sudo openssl rsa -in /etc/imboy/keys/login_rsa_priv.pem \
-pubout -out /etc/imboy/keys/login_rsa_pub.pem
sudo chmod 600 /etc/imboy/keys/login_rsa_priv.pem
sudo chmod 644 /etc/imboy/keys/login_rsa_pub.pem
sudo chown -R imboy:imboy /etc/imboy/keys5. 启动 PostgreSQL / Start PostgreSQL
中文:在仓库根目录按 profile 显式选择 PG 服务,避免启动其他本地服务;后端 release 仍单独启动。pro 与生产 profiles 共用同一个 PostgreSQL 服务。复用原 5181 数据库前,按本地开发指南显式指定原目录和端口。
English: Explicitly select the PostgreSQL service and profile in the repository-root docker-compose.yml. The pro and production profiles share one PostgreSQL service. Before reusing the former database on port 5181, configure its path and port as described in the local development guide. Start the backend release separately.
bash
# 开发 / Development (port 4323)
docker compose --profile dev up -d imboy_pg18
# 仅启动生产 PostgreSQL / Start production PostgreSQL only
docker compose --profile prod up -d prod_imboy_pg18
# 同时多实例 / Combined
docker compose --profile dev --profile prod up -d imboy_pg18 prod_imboy_pg18中文:原
--profile turn(coturn)已删除 —— TURN 由 LiveKit embedded TURN 承载, 不再是独立 compose 服务(部署与开启方式见 livekit-single-service-runbook.md)。 未设置IMBOY_PG_PASSWORD时 docker compose 会立刻报错并拒绝启动,不会留下默认密码风险。 English: WithIMBOY_PG_PASSWORDunset,docker composeerrors out immediately — no default-password risk.
6. 构建并发布 / Build & release
bash
# 构建 release tarball / Build release tarball
make
# 解压并启动 / Extract and start
tar xf _rel/imboy/imboy-1.0.0-rc.1.tar.gz -C /opt/imboy
cd /opt/imboy && IMBOYENV=prod ./bin/imboy daemon中文:版本号以
relx.config版本行为准(须与VERSION一致);RELX_REL_VSN环境变量不生效,临时改版请直接编辑relx.config后还原。 English: The release version comes fromrelx.config(keep it in sync withVERSION); theRELX_REL_VSNenv var is not honored — for a one-off version, editrelx.configdirectly and revert afterwards.
7. 健康检查 / Health check
bash
# Erlang 节点 ping / Ping Erlang node
/opt/imboy/bin/imboy ping
# HTTP 心跳 / HTTP healthcheck
curl -fsS http://127.0.0.1:9800/healthz蓝绿切换 / Blue-green switch
中文:备机 9801,前置 nginx/七层 LB 改 upstream 后 reload,旧版 9800 静置 5 分钟回收。 English: Standby on 9801; flip nginx/L7 LB upstream and reload, then drain old 9800 for ~5 min.
nginx
upstream imboy {
server 127.0.0.1:9800; # 切换时改成 9801 / swap to 9801 on flip
}故障排查 / Troubleshooting
| 现象 / Symptom | 原因 / Cause | 处理 / Fix |
|---|---|---|
error({missing_required_config, jwt_key}) | IMBOY_JWT_KEY 未设置 / unset | 设置环境变量后重启 / set env and restart |
insecure_pg_password | 数据库使用了弱密码(如 password、123456、空)/ weak DB password | 改强密码并 rotate / rotate to strong password |
insecure_config: api_auth_switch | 生产未开启 API 签名 / API sig disabled in prod | IMBOY_API_AUTH_SWITCH=on |
通话入会报 livekit_not_configured | LiveKit 三键(ws_url/api_key/api_secret)任一为空 / any LiveKit key empty | 补齐 IMBOY_LIVEKIT_*(或 compose 的 LIVEKIT_API_KEY/SECRET)后重启 / set them and restart |
solidified_key not configured (warning) | dev/local 使用稳定默认值 / stable dev default | 生产请显式设置 IMBOY_SOLIDIFIED_KEY* / set explicitly in prod |
login_rsa_*_key_file not configured (warning) | dev/local 落盘到 priv/dev_keys/ / persisted to priv/dev_keys | 生产请配置 IMBOY_LOGIN_RSA_*_FILE 指向 release 外路径 / point to path outside release |
参考 / References
- 完整生产部署指南 / Full production guide:
deployment.md - 备份与恢复 / Backup & restore:
backup-restore.md - 监控 / Monitoring:
monitoring.md - 环境变量映射源码 / Env var mapping source:
src/lib/imboy_env.erl - Fail-fast 校验源码 / Fail-fast validation source:
src/imboy_app.erl: validate_runtime_config/0