feat(sfu): ship the prebuilt sidecar binary in the package (true plug-and-play)

Backend-hosted rooms now work on a plain `composer require`/`update` with no
download step: rust/dist/blax-webrtc-sfu-linux-x86_64 (+ .sha256) is committed
and BinaryManager::find() resolves rust/dist/blax-webrtc-sfu-<platform> before
the download fallback. A consuming app just sets WEBRTC_MEDIA_ENGINE=
RustMediaEngine (+ pin/publish WEBRTC_SFU_UDP_PORT and WEBRTC_SFU_PUBLIC_IP for
prod) and the sidecar auto-spawns.

- .gitignore: keep rust/target/ ignored, COMMIT rust/dist/ (shipped binaries)
- BinaryManager: add shipped-binary resolution + doc; README/doc updated

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Blax Software 2026-07-22 10:08:14 +02:00
parent c75f9122d4
commit 9af8281518
4 changed files with 11 additions and 3 deletions

6
.gitignore vendored
View File

@ -7,6 +7,8 @@ composer.lock
.idea/
.vscode/
# Rust build artifacts (Cargo.lock IS committed — bin crate, reproducible releases)
# Rust build artifacts (Cargo.lock IS committed — bin crate, reproducible releases).
# rust/target/ is local build output. rust/dist/ IS committed: it holds the
# prebuilt release binaries (+ .sha256) SHIPPED with the package for plug-and-play
# (BinaryManager::find resolves rust/dist/blax-webrtc-sfu-<platform> — no download).
/rust/target/
/rust/dist/

BIN
rust/dist/blax-webrtc-sfu-linux-x86_64 vendored Executable file

Binary file not shown.

View File

@ -0,0 +1 @@
79840ef020c334d9bdab5fcf5f72be918d444a6bdc6e9236574bd019357672b5 blax-webrtc-sfu-linux-x86_64

View File

@ -45,7 +45,7 @@ class BinaryManager
return (string) ($this->config['version'] ?? self::VERSION);
}
/** First usable binary (override → dev build → installed), or null. */
/** First usable binary (override → dev build → shipped → installed), or null. */
public function find(): ?string
{
$packageRoot = dirname(__DIR__, 3);
@ -54,6 +54,11 @@ class BinaryManager
$this->config['binary'] ?? null,
$devBuilds ? $packageRoot.'/rust/target/release/blax-webrtc-sfu' : null,
$devBuilds ? $packageRoot.'/rust/target/debug/blax-webrtc-sfu' : null,
// Plug-and-play: the prebuilt binary SHIPPED with the package (composer
// installs it alongside the PHP), resolved per platform. This is what
// makes backend-hosted rooms work on `composer require`/`update` with
// no download step — see rust/dist/ (committed).
$packageRoot.'/rust/dist/blax-webrtc-sfu-'.$this->platform(),
$this->installPath(),
]);