CI / release-notes (push) Canceled after 0s
CI / validate (push) Canceled after 0s
CI / release-server (amd64, piik-server, linux, ubuntu-latest) (push) Canceled after 0s
CI / release-server (amd64, piik-server-windows-amd64, windows, ubuntu-latest) (push) Canceled after 0s
CI / release-server (arm64, piik-server-linux-arm64, linux, ubuntu-24.04-arm) (push) Canceled after 0s
CI / release-apps (macos-15, darwin-arm64) (push) Canceled after 0s
CI / release-apps (macos-15-intel, darwin-amd64) (push) Canceled after 0s
CI / release-apps (ubuntu-24.04, android-universal) (push) Canceled after 0s
CI / release-apps (ubuntu-24.04, linux-amd64) (push) Canceled after 0s
CI / release-apps (ubuntu-24.04-arm, linux-arm64) (push) Canceled after 0s
CI / release-apps (windows-latest, windows-amd64) (push) Canceled after 0s
CI / publish (push) Canceled after 0s
91 lines
4.2 KiB
Markdown
91 lines
4.2 KiB
Markdown
# 在 Linux 服务器上构建 Piik(实测记录)
|
||
|
||
本仓库是 [TNTcraftHIM/Piik](https://github.com/TNTcraftHIM/Piik) 的镜像(GPL/MIT 见各自文件,Piik 本体 MIT)。
|
||
以下命令在 **OpenCloudOS 9 x86_64 / 4 核 / 3 GB 内存** 上跑通,时间为 2026-11-30,代码版本 `v2.8.0`(commit `81b4f27`)。
|
||
|
||
## 0. 版本要求(`package.json` / `.node-version` / `go.mod` 已写明)
|
||
|
||
| 组件 | 要求 | 说明 |
|
||
|---|---|---|
|
||
| Node | `>=24 <27`,`.node-version` 是 `24.22.3` | Node 20 会被 `engines` 拒绝 |
|
||
| npm | `11.x` | 项目声明 `packageManager: npm@11.17.0` |
|
||
| Go | `go 1.27.4` | 低于此版本 `go build` 直接报 `go.mod requires go >= 1.27.4` |
|
||
|
||
服务器原先只有 Node 20 且没有 Go,因此先装工具链(二者都是解压即用,不影响系统包):
|
||
|
||
```bash
|
||
mkdir -p /opt/toolchains && cd /opt/toolchains
|
||
curl -sSL -o node24.tar.xz https://npmmirror.com/mirrors/node/v24.22.3/node-v24.22.3-linux-x64.tar.xz
|
||
tar xf node24.tar.xz && mv node-v24.22.3-linux-x64 node
|
||
curl -sSL -o go.tgz https://mirrors.aliyun.com/golang/go1.27.4.linux-amd64.tar.gz
|
||
tar xf go.tgz
|
||
export PATH=/opt/toolchains/node/bin:/opt/toolchains/go/bin:$PATH
|
||
export GOPROXY=https://goproxy.cn,https://mirrors.aliyun.com/goproxy/,direct
|
||
node -v && go version
|
||
```
|
||
|
||
## 1. 依赖
|
||
|
||
```bash
|
||
npm config set registry https://registry.npmmirror.com
|
||
npm ci --no-audit --no-fund # 约 30 秒
|
||
go mod download # 约 2 分钟(含 livekit 等大依赖)
|
||
```
|
||
|
||
## 2. 构建
|
||
|
||
**只想跑起来**(最快,出两个可执行文件):
|
||
|
||
```bash
|
||
npm run build:web # Vite 产物写入 internal/server/webassets/dist(被 Go 二进制 embed)
|
||
go build -trimpath -p 2 -o dist/piik-server ./cmd/piik-server
|
||
go build -trimpath -p 2 -o dist/piik-app ./cmd/piik-app
|
||
```
|
||
|
||
**要出官方同款发布包**(推荐,带 `-s -w` 与版本号、附 manifest 与校验和):
|
||
|
||
```bash
|
||
node scripts/package-server-release.mjs /tmp/piik-release --os linux --arch amd64
|
||
# → piik-<rev>-runtime.tar.gz / .manifest.tsv / .release.json
|
||
```
|
||
|
||
脚本要求工作区干净、输出目录不存在;版本号取自 `git tag --points-at HEAD`,不在 tag 上会得到 `development`,
|
||
所以要么 `git checkout v2.8.0` 再打包,要么显式指定 `PIIK_BUILD_VERSION=v2.8.0`。
|
||
|
||
**桌面 App 包**(需要 cloudflared,用于临时公网邀请):
|
||
|
||
```bash
|
||
curl -sSL -o /tmp/cloudflared https://github.com/cloudflare/cloudflared/releases/download/2026.10.3/cloudflared-linux-amd64
|
||
sha256sum /tmp/cloudflared # 053b80b0…(脚本内置校验值)
|
||
node scripts/assemble-app.mjs /tmp/piik-release/piik-<rev>.release.json /tmp/piik-app \
|
||
--target linux-amd64 --tunnel /tmp/cloudflared
|
||
```
|
||
|
||
## 3. 运行与自检
|
||
|
||
```bash
|
||
mkdir -p /opt/piik && tar xzf piik-<rev>-runtime.tar.gz -C /opt/piik
|
||
cd /opt/piik && ./piik-server # 默认 0.0.0.0:8787
|
||
```
|
||
|
||
实测结果:
|
||
|
||
- `GET /` → **200**,返回内嵌的 Web UI(`<title>Piik</title>`);
|
||
- `GET /assets/index-*.js`(`index.html` 里引用的主包)→ **200**;
|
||
- 日志:`Piik server is listening … version=v2.8.0 revision=81b4f27e… port=8787 sqlite=true`;
|
||
- `./piik-server --check-config` 可用于校验环境变量;`--check-release` 会联网比对上游最新 release(实测返回上游 `v2.8.0`);
|
||
- 房间数据在 SQLite(默认随进程工作目录生成),站点默认不开启访问保护与 SFU,生产使用请按
|
||
[`docs/operations/self-hosting.md`](./operations/self-hosting.md) 配 HTTPS 反代、域名与 STUN。
|
||
|
||
## 4. 这套环境做不了什么
|
||
|
||
- **Android APK**:`scripts/build-android.mjs` 需要 Android SDK/NDK 与 Gradle 环境(本机只有 android.jar,缺 NDK)。
|
||
- **Windows / macOS 包**:`assemble-app.mjs` 的目标平台与 Node 平台必须一致(`--target windows-amd64` 在 Linux 上会被拒绝)。
|
||
- **原生采集运行时 `piik-capture`**:需要 `go run ./cmd/piik-capture` 对应的 cgo/libwebrtc 依赖链,本轮未构建,
|
||
因此 App 包里 `nativeCapture: null`(浏览器采集不受影响)。
|
||
|
||
## 5. 已经产出的成品
|
||
|
||
见本仓库 Releases:`piik-81b4f27-runtime.tar.gz`(Linux x64 服务端运行时,15 MB)、
|
||
`piik-app-linux-amd64-v2.8.0.tar.gz`(桌面 App,36 MB)、manifest 与 release 描述文件。
|