Skip to content

Bake the p2p discovery sidecar into the image at build time - #37

Merged
aptalca merged 2 commits into
linuxserver:p2p-sidecarfrom
IrosTheBeggar:bake-p2p-sidecar
Aug 31, 2026
Merged

Bake the p2p discovery sidecar into the image at build time#37
aptalca merged 2 commits into
linuxserver:p2p-sidecarfrom
IrosTheBeggar:bake-p2p-sidecar

Conversation

@IrosTheBeggar

Copy link
Copy Markdown
Contributor

linuxserver.io


  • I have read the contributing guideline and understand that I have made the correct modifications

Description:

mStream 6.21+ ships a p2p discovery feature whose helper binary (the p2p-sidecar) is fetched on first use — sha256-verified against a manifest committed in the app tree. This PR runs the app's own pre-fetch script (scripts/fetch-p2p-sidecar.mjs, provided upstream for exactly this image-bake case) during the image build, right after npm install, so the binary ships inside the image. Applied identically to Dockerfile and Dockerfile.aarch64 (each arch fetches its own musl build at build time), plus a changelog line in readme-vars.yml.

Benefits of this PR and context:

  • Discovery works in containers without runtime egress to github.com — outbound-restricted setups currently can't use the feature at all.
  • No first-enable download latency; the container is self-sufficient the way it already is for ffmpeg/onnxruntime (installed via apk).
  • Supply chain unchanged: the build-time fetch verifies the same committed sha256 pins the runtime fetch uses, and a failed or tampered download fails the image build loudly (the script exits non-zero). Image size cost: ~8.6 MB.
  • Fully backward-compatible: without the baked binary, mStream's runtime fetch into /config continues to work as today.

I'm the mStream maintainer's agent-assisted contribution; the distribution model is documented at docs/p2p-sidecar-distribution.md and bin/p2p-sidecar/README.md.

How Has This Been Tested?

Built the x86_64 image from this branch (pulls the current mStream release, v6.21.2). Then in a --network none container:

  • /app/mstream/bin/p2p-sidecar/p2p-sidecar-linux-x64-musl is present, owned by abc, executable (8.6 MB);
  • running it as abc with --print-id returns a valid node id — the discovery helper works with zero network access.

Source / References:

mStream 6.21+ fetches its p2p discovery sidecar binary on first use,
sha256-verified against a manifest committed in the app tree. Baking it
at image build (the app ships a script for exactly this) means discovery
works in containers with no runtime egress to github.com and with no
first-enable download; the fetch is pinned+verified either way, and
images inherit new pins on their normal rebuilds. Runtime fetch remains
as the fallback for anything else, so nothing breaks for older images.

Verified: built the x86_64 image, then in a --network none container the
baked binary executes (--print-id returns a valid node id) as user abc.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Comment thread Dockerfile Outdated
npm link && \
chmod +x /app/mstream/bin/rust-parser/* && \
echo "**** bake the p2p discovery sidecar (manifest-pinned, sha256-verified) ****" && \
su -s /bin/sh abc -c 'HOME=/tmp node scripts/fetch-p2p-sidecar.mjs' && \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running this as abc is not necessary as abc at this point has a placeholder uid of 911 assigned, which will change runtime.

Our init script has a recursive chown for the /app/mstream/bin, which should take care of the perms runtime.

@aptalca
aptalca changed the base branch from master to p2p-sidecar August 31, 2026 18:21
@aptalca
aptalca merged commit f369ceb into linuxserver:p2p-sidecar Aug 31, 2026
2 checks passed
@LinuxServer-CI LinuxServer-CI moved this from PRs to Done in Issue & PR Tracker Aug 31, 2026
@aptalca aptalca mentioned this pull request Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants