62 lines
2.6 KiB
Markdown
62 lines
2.6 KiB
Markdown
# 0.2.1 独立验证部署 (baihu /app/iboard-0.2.1)
|
||
|
||
与现网 `/app/iboard`(3001/宿主 MySQL) 完全隔离:本栈使用独立 PG 容器、端口 13443/13001/13002,不写原库。
|
||
|
||
**浏览器入口: `https://bh.vps.honor3.com:13443`**(自签证书,首次访问需在浏览器"高级→继续访问"接受一次;PowerSync 网页端必须运行在安全上下文,http://13001 入口仅供接口调试,任务模块会报 Navigator locks 错误)。
|
||
正式启用需替换受信证书:把 `bh.pem/bh.key` 换成受信证书后 `docker compose restart tls-front`(例如 Let's Encrypt DNS-01,80/443 已被 gateway 占用无法 HTTP-01)。
|
||
|
||
## 栈
|
||
|
||
| 服务 | 说明 |
|
||
| --- | --- |
|
||
| `pg` | postgres:16-alpine,`wal_level=logical`(供 PowerSync 逻辑复制),数据在 `./data/pg`,**不对外暴露端口** |
|
||
| `app` | 本仓库 Dockerfile 构建,13001 对外;启动时先 `prisma migrate deploy`;`DISABLE_CRON=1` 关闭定时任务 |
|
||
| `powersync` | journeyapps/powersync-service,13002 对外;源库=pg,bucket storage=同实例 PG 的 powersync schema |
|
||
|
||
## 首次部署
|
||
|
||
```bash
|
||
# 服务器上 (源码已上传到 /app/iboard-0.2.1)
|
||
cd /app/iboard-0.2.1/deploy/0.2.1
|
||
|
||
# 1. 生成 .env (参照 .env.example; POWERSYNC_JWT_KEY_B64 由 secret 派生)
|
||
umask 077
|
||
PG_PASSWORD=$(openssl rand -hex 16)
|
||
PS_STORAGE_PASSWORD=$(openssl rand -hex 16)
|
||
JWT_SECRET_021=$(openssl rand -hex 32)
|
||
POWERSYNC_JWT_SECRET=$(openssl rand -hex 32)
|
||
POWERSYNC_JWT_KEY_B64=$(printf %s "$POWERSYNC_JWT_SECRET" | openssl base64 -A | tr '+/' '-_' | tr -d '=')
|
||
cat > .env <<EOF
|
||
PG_PASSWORD=$PG_PASSWORD
|
||
PS_STORAGE_PASSWORD=$PS_STORAGE_PASSWORD
|
||
JWT_SECRET_021=$JWT_SECRET_021
|
||
POWERSYNC_JWT_SECRET=$POWERSYNC_JWT_SECRET
|
||
POWERSYNC_JWT_KEY_B64=$POWERSYNC_JWT_KEY_B64
|
||
POWERSYNC_URL=http://bh.vps.honor3.com:13002
|
||
OTA_PUBLIC_BASE=http://bh.vps.honor3.com:13001
|
||
EOF
|
||
|
||
# 2. 构建并启动
|
||
docker compose build app
|
||
docker compose up -d
|
||
|
||
# 3. 验证
|
||
docker compose ps
|
||
curl -s http://127.0.0.1:13001/api/health
|
||
docker compose logs powersync --tail 50 # 应看到连接源库/建 publication/sync config 部署成功
|
||
```
|
||
|
||
## 日常更新
|
||
|
||
```bash
|
||
cd /app/iboard-0.2.1
|
||
git archive 方式重新上传源码 tar 后解包覆盖 (data/.env 不受影响)
|
||
cd deploy/0.2.1 && docker compose build app && docker compose up -d app
|
||
```
|
||
|
||
## 注意
|
||
|
||
- `./data/pg` 为 0.2.1 独立数据卷;`./.env` 为密钥,两者均已 gitignore,更新源码时不会覆盖 `.env`(tar 解包不产生它)。
|
||
- PowerSync 的 publication / replication slot 由 service 自动管理(账号 iboard021 为容器内 superuser)。
|
||
- 同步规则改动:编辑 `powersync/sync-config.yaml` 后 `docker compose restart powersync`。
|