Files
Piik/docs/operations/github.md
T
AAA 02e71621f2 feat(deploy): ship Server containers and repair NAT-PMP mappings (#400)
## Problem and outcome / 问题与结果

Self-hosting currently requires assembling a Server installation, while App port mappings can use the wrong external port or remain active after cancellation. This phase adds a verified Linux x64 Server image and Compose recipe, and repairs the existing NAT-PMP dependencies so mapping results, cancellation and cleanup follow the gateway response and request lifetime.

The image wraps the exact verified Server archive and is tested before publication. Version tags retain their original image; `latest` follows the latest published GitHub release. The two scoped dependency replacements retain upstream source, tests and licenses, with their removal criteria documented in `internal/thirdparty/README.md`.

Planned release: **v1.3.0** (compatible Docker distribution feature plus NAT fixes).

## Release notes

### 中文

- 新增 Linux x64 Docker 镜像与 Compose 部署方式,内置网页、信令和 STUN,可按需开启 SFU 兜底。提供部署、更新与备份教程。
- 修复 App 的 NAT-PMP 端口映射:正确使用路由器分配的外部端口,并在关闭时尝试删除映射。
- NAT-PMP 请求会随取消或超时结束,避免连接尝试结束后继续在后台重试。

已有配置和房间数据格式保持兼容,更新无需迁移。

### English

- Added a Linux x64 Docker image and Compose setup with the Web UI, signaling, STUN and optional SFU fallback, plus deployment, update and backup guides.
- Fixed App NAT-PMP mappings to use the external port assigned by the router and attempt mapping removal on shutdown.
- NAT-PMP requests now stop on cancellation or timeout, preventing retries from continuing after a connection attempt has ended.

Existing configuration and room data formats remain compatible; no migration is required.

## Verification / 验证

[Candidate CI](https://github.com/TNTcraftHIM/Piik/actions/runs/34761969362) passed for `1d8de6c4690434cd2cf44fbdee4f45b1776432fa`. The final two files changed after that run are documentation only (`docs/todo.md` and `docs/verification-status.md`), with repository hygiene checked separately.

- Web type checks, unit tests and production build; Go core tests, vet and target builds; NAT and media-edge race detection.
- Actual packaged-image checks with Docker Compose: production startup, embedded Web, UDP STUN, optional SFU startup, retained room authority across recreation, diagnostic ZIP export, non-root/read-only execution and clean shutdown.
- Windows x64, Linux x64 and macOS arm64 App packaging.
- Scoped NAT dependency regressions cover assigned ports, renewal, deletion, cancellation, lost replies and PCPv6 composition using real local UDP endpoints.

The publishing pipeline reruns the image checks for the merged release revision. First publication also requires making the GHCR package public and checking anonymous pulls of its version and `latest` tags. Representative physical routers, public-media networks and operator-specific HTTPS/firewall settings remain outside the container smoke test.

## Impact / 影响

No signaling, native-control or storage-format change. Existing App/Server installations remain compatible. Docker supports `linux/amd64` in this phase; its default is P2P, and SFU remains an explicit deployment option. Existing deployments keep their configuration.

README, bilingual self-hosting guides, container maintenance, versioning, dependency provenance and NAT evidence are updated. Completed feedback is removed from TODO; ongoing network evidence remains tracked there.
2026-09-13 23:09:14 +08:00

7.0 KiB

GitHub Repository And Releases

Versioning owns release meaning and compatibility; CONTRIBUTING owns review and local validation. This file owns the one-time GitHub settings. The source repository is public; automatic package publication has its own activation gate below.

Main And Pull Requests

Use squash merging only, with the PR title and body as the squash commit. These repository settings are applied. Keep automatic branch deletion off: the normal cleanup step checks local worktrees and remaining references first.

Protect main with PRs required, zero mandatory peer approvals for the solo maintainer, administrator enforcement, linear history, and no force pushes or deletions. Do not require cloud PR checks while branch/PR CI is intentionally quiet; local validation and acceptance precede the squash merge. PR/issue templates live in .github/; naming is shared with automatic version selection.

These protections are active, including conversation resolution. GitHub Pages uses the GitHub Actions publishing source and the piik.tv custom domain; the repository homepage points to https://piik.tv. The dedicated Website workflow publishes the static site under website operations.

Enable Automatic Publication Once

Before enabling, accept the release packages, compatibility baseline, public copy and repository visibility; finish main protection. Then set repository Actions variable PIIK_RELEASES_ENABLED to true. This is a repository setting, not an environment variable for Piik App or Server.

Subsequent accepted PRs merged to main use the existing CI workflow. Product changes calculate one version, validate, package Server and all App targets, and publish the same artifacts. Standalone website/docs changes validate without packaging or releasing; versioning owns that boundary. Runs queue rather than overlap or cancel one another. Branches/PRs stay quiet; manual client_checks dispatch remains available for candidates. Writing a new version back to main is unnecessary and prohibited.

For a complete publisher rehearsal, dispatch with client_checks: true and an explicit candidate_version such as v1.0.0. This builds genuine Server and native App artifacts under one revision and version without tagging or publishing. Prepare its release-note section and inspect the generated preview in the run summary. For a local preview, run node scripts/release-notes.mjs v1.0.0 FULL_SOURCE_SHA from the checkout with full history and tags. Download that run's artifacts and pass their directory, version and full revision to scripts/publish-release.mjs --dry-run (put the flag after the three positional arguments). An omitted candidate version keeps the usual development/exact-tag identity.

Enable GitHub's built-in release immutability for formal publication where available. Upload all assets to the draft before publishing. A failed upload can resume its same-source draft; a published version is never clobbered. If its files are wrong or incomplete, publish a corrected new version. An older retry must not replace a newer release's latest designation.

To stop future automatic publication, remove/set false the activation variable; this does not alter existing releases or a currently running workflow. Inspect the active run separately. No pipeline step changes visibility or installs an update into a running Piik deployment.

Container Registry

The Server image uses ghcr.io/tntcrafthim/piik. The publishing job authenticates with GITHUB_TOKEN and packages: write; no additional registry secret is needed. The image's source label links it to this repository. GitHub's Container registry guide owns the registry permission and visibility behavior.

At first publication, set the Piik container package's visibility to public in its GitHub package settings; repository visibility alone does not do this. Verify both its version tag and latest with an anonymous pull before announcing the Docker download. Keep repository Actions access enabled for later releases. Image checks, version identity and retries follow container distribution.

Gitee Download Mirror

TNTcraftHIM/Piik is a public README/Release mirror. Source, documentation and issues stay on GitHub. The publishing job uses the repository Actions secret GITEE_TOKEN, which is configured; rotate it there when needed. Never put it in source, a remote URL or a distributed package. GitHub publication continues to use the workflow's scoped token.

After GitHub publication, the same job runs scripts/mirror-release.mjs on the original artifacts. Upload failure leaves the Gitee release marked as a preview. Rerun the failed publishing job to verify existing files and upload only missing ones. GitHub's published release remains unchanged. Both publishers reject changing a published package; use a corrected new version if its bytes are wrong.

For a local retry, use the original complete build output retained outside the checkout. While the publishing run's artifacts are available, download all four into one directory (replace RUN_ID, FULL_SOURCE_SHA and VERSION):

for artifact in piik-server piik-app-windows-amd64 piik-app-linux-amd64 piik-app-darwin-arm64; do
  gh run download RUN_ID --repo TNTcraftHIM/Piik \
    --name "$artifact-FULL_SOURCE_SHA" --dir /tmp/piik-mirror
done
node scripts/mirror-release.mjs /tmp/piik-mirror VERSION FULL_SOURCE_SHA

Use a fresh directory. Public Release downloads contain only runtime archives; mirror verification also needs the original descriptors, manifest and checksum files. If CI artifacts have expired, recover that complete output from the operator's retained copy. Rebuilding a published version is not a metadata recovery procedure. See artifact retention.

Use the release's actual version and full target_commitish SHA, with GITEE_TOKEN supplied through the publisher environment. --dry-run after the three arguments checks local identity, checksums and attachment sizes without publishing. The release-source policy owns provenance, selection and quota limits. The first public release passed complete matching Server and three-platform App mirror download acceptance.

Platform References