Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Dockerfile for SFU #431

Merged
merged 5 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/container-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,12 @@ jobs:
tags: 'ghcr.io/epicgames/pixel-streaming-signalling-server:5.4'
push: true
file: SignallingWebServer/Dockerfile
-
name: Build and push the SFU container image
uses: docker/build-push-action@v3
with:
context: .
tags: 'ghcr.io/epicgames/pixel-streaming-sfu:5.4'
push: true
file: SFU/Dockerfile

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ The following container images are built from this repository:

- [ghcr.io/epicgames/pixel-streaming-signalling-server](https://github.com/orgs/EpicGames/packages/container/package/pixel-streaming-signalling-server) (since Unreal Engine 5.1)
( This link requires you to join Epic's Github org )
- [ghcr.io/epicgames/pixel-streaming-sfu](https://github.com/orgs/EpicGames/packages/container/package/pixel-streaming-sfu) (since Unreal Engine 5.4)
( This link requires you to join Epic's Github org )

### NPM Packages
The following are `unofficial` NPM packages (official ones coming soon):
Expand Down
13 changes: 13 additions & 0 deletions SFU/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Use the current Long Term Support (LTS) version of Node.js
FROM node:lts

COPY /SFU /SFU

RUN SFU/platform_scripts/bash/setup.sh

ENV SIGNALLING_URL ws://localhost:8889

EXPOSE 40000-49999/tcp
EXPOSE 40000-49999/udp

CMD node /SFU/sfu_server.js --signallingURL=${SIGNALLING_URL}
8 changes: 8 additions & 0 deletions SFU/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,11 @@ Launch the streaming app with the following arguments
This tells the Pixel Streaming plugin to stream simulcast with 3 streams, each one scaling video resolution by half. The sequence of values is as follows, `scale_down_factor,min_bitrate,max_bitrate,...repeating for each stream`

When this streams to the SFU, the SFU will detect these 3 streams and then selectively stream these out to connected peers based on their connection quality.

## Running the Docker image

The Docker image needs to know where the signalling server to connect to is. You will need to set the `SIGNALLING_URL` environment variable to the URL for your signalling server. This URL needs to point to the configured SFU port (default 8889).
You will also need to use the `host` network driver on docker because of the way the SFU collects and reports its available ports.
An example for running might be as follows.

```docker run -e SIGNALLING_URL=ws://192.168.1.10:8889 --network="host" ghcr.io/epicgames/pixel-streaming-sfu:5.4```
46 changes: 32 additions & 14 deletions SFU/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions SFU/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
"private": true,
"scripts": {
"start-local": "run-script-os --",
"start-local:windows": ".\\platform_scripts\\cmd\\run.bat",
"start-local:default": "./platform_scripts/bash/run_local.sh",
"start-local:windows": ".\\platform_scripts\\cmd\\run.bat",
"start-local:default": "./platform_scripts/bash/run_local.sh",
"start-cloud": "run-script-os --",
"start-cloud:windows": ".\\platform_scripts\\cmd\\run_cloud.bat",
"start-cloud:default": "./platform_scripts/bash/run_cloud.sh",
"start-cloud:windows": ".\\platform_scripts\\cmd\\run_cloud.bat",
"start-cloud:default": "./platform_scripts/bash/run_cloud.sh",
"start": "run-script-os",
"start:windows": "platform_scripts\\cmd\\node\\node.exe sfu_server.js",
"start:default": "if [ `id -u` -eq 0 ]\nthen\n export process=\"./platform_scripts/bash/node/bin/node sfu_server.js\"\nelse\n export process=\"sudo ./platform_scripts/bash/node/bin/node sfu_server.js\"\nfi\n$process "

"start:windows": "platform_scripts\\cmd\\node\\node.exe sfu_server.js",
"start:default": "if [ `id -u` -eq 0 ]\nthen\n export process=\"./platform_scripts/bash/node/bin/node sfu_server.js\"\nelse\n export process=\"sudo ./platform_scripts/bash/node/bin/node sfu_server.js\"\nfi\n$process "
},
"dependencies": {
"mediasoup-sdp-bridge": "file:mediasoup-sdp-bridge",
"ws": "^7.1.2",
"mediasoup_prebuilt": "^3.8.4",
"run-script-os": "^1.1.6"
"mediasoup-sdp-bridge": "file:mediasoup-sdp-bridge",
"minimist": "^1.2.8",
"run-script-os": "^1.1.6",
"ws": "^7.1.2"
}
}
7 changes: 7 additions & 0 deletions SFU/sfu_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const config = require('./config');
const WebSocket = require('ws');
const mediasoup = require('mediasoup_prebuilt');
const mediasoupSdp = require('mediasoup-sdp-bridge');
const minimist = require('minimist');

if (!config.retrySubscribeDelaySecs) {
config.retrySubscribeDelaySecs = 10;
Expand Down Expand Up @@ -351,6 +352,12 @@ async function createWebRtcTransport(identifier) {
}

async function main() {
var argv = minimist(process.argv.slice(2));

if ('signallingURL' in argv) {
config.signallingURL = argv['signallingURL'];
}

console.log('Starting Mediasoup...');
console.log("Config = ");
console.log(config);
Expand Down
2 changes: 1 addition & 1 deletion SignallingWebServer/platform_scripts/bash/common_utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function use_args() {
}

function call_setup_sh() {
bash "setup.sh"
bash "setup.sh" $*
}

function start_process() {
Expand Down
7 changes: 4 additions & 3 deletions SignallingWebServer/platform_scripts/bash/run_local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ pushd "${BASH_LOCATION}" > /dev/null
source common_utils.sh

set_start_default_values "n" "n" # No server specific defaults
use_args "$@"
call_setup_sh
use_args "$*"
call_setup_sh $*
print_parameters

process="${BASH_LOCATION}/node/lib/node_modules/npm/bin/npm-cli.js run start:default --"
Expand All @@ -33,4 +33,5 @@ start_process $process $arguments

popd > /dev/null # ../..

popd > /dev/null # BASH_SOURCE
popd > /dev/null # BASH_SOURCE

2 changes: 1 addition & 1 deletion SignallingWebServer/platform_scripts/bash/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pushd "${BASH_LOCATION}" > /dev/null

source common_utils.sh

use_args $@
use_args $*
# Azure specific fix to allow installing NodeJS from NodeSource
if test -f "/etc/apt/sources.list.d/azure-cli.list"; then
sudo touch /etc/apt/sources.list.d/nodesource.list
Expand Down