Skip to content
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
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ JVB_ADVERTISE_IPS=
#
# Local dev:
# MEDIAMTX_WHIP_BASE=http://localhost:8889

# Public IPs or hostnames MediaMTX advertises for WebRTC media (UDP 8189), comma-separated.
# Defaults to JVB_ADVERTISE_IPS, which is the server's public IP in production.
# MEDIAMTX_PUBLIC_HOSTS=
#
# Production (voxbento.com) — Caddy proxies:
# */{path}/whip → localhost:8889 (WHIP ingest)
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
set -e

echo "=== Deploying to production: $(date) ==="
cd /home/ubuntu/voxbento
cd "${VOXBENTO_DIR:-$HOME/voxbento}"

# Validate in a separate checkout: the current portal may still bind
# the live source directory until this deployment replaces it.
Expand Down Expand Up @@ -132,7 +132,7 @@ jobs:
# Keep the previous images available until the replacement stack is
# healthy. This preserves rollback options during a failed rollout.
echo "--- cleaning up unused images ---"
docker image prune -f
docker image prune -f --filter label=com.docker.compose.project=voxbento

# The rootless Jitsi layout uses new volumes. Remove the five
# pre-rootless generated-config volumes once no container uses them.
Expand Down
8 changes: 4 additions & 4 deletions Caddyfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
# sudo systemctl reload caddy
#
# DNS requirements:
# A voxbento.com → 100.56.6.172
# A jitsi.voxbento.com → 100.56.6.172
# A rtmps.voxbento.com → 100.56.6.172 (DNS only; no Cloudflare proxy)
# A voxbento.com → <server public IP>
# A jitsi.voxbento.com → <server public IP>
# A rtmps.voxbento.com → <server public IP> (DNS only; no Cloudflare proxy)
#
# Caddy handles TLS automatically via Let's Encrypt.
#
Expand Down Expand Up @@ -74,7 +74,7 @@ voxbento.com {
# Jitsi web runs in Docker on host port 8080 (HTTP).
# Caddy provides HTTPS termination so the iframe loads securely inside the portal.
#
# Required: DNS A record jitsi.voxbento.com → 100.56.6.172
# Required: DNS A record jitsi.voxbento.com → <server public IP>
# Note: JVB media (UDP 10000) connects DIRECTLY to the server, not via Caddy.
jitsi.voxbento.com {
# Forward all requests including WebSocket (BOSH, Colibri) to Jitsi web.
Expand Down
3 changes: 3 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ services:
- ./mediamtx.yml:/mediamtx.yml:ro
environment:
MTX_AUTHHTTPADDRESS: "http://portal:8000/internal/media-auth?key=${MEDIAMTX_AUTH_HOOK_SECRET:-}"
# ICE host candidates browsers use to reach UDP 8189. Replaces the list in mediamtx.yml.
# Defaults to the public IPs Jitsi already advertises (JVB_ADVERTISE_IPS).
MTX_WEBRTCADDITIONALHOSTS: "127.0.0.1,${MEDIAMTX_PUBLIC_HOSTS:-${JVB_ADVERTISE_IPS:-127.0.0.1}}"
ports:
- "127.0.0.1:8888:8888" # HTTPS proxy only
- "127.0.0.1:8889:8889" # HTTPS proxy only
Expand Down
8 changes: 4 additions & 4 deletions mediamtx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ webrtcLocalUDPAddress: :8189 # single UDP port for all ICE traffic (replaces de
# cannot reach. Adding 127.0.0.1 ensures the SDP answer includes a
# localhost ICE candidate so the browser can connect via the port-forwarded
# UDP port 8189.
#
# Under Docker Compose this list is replaced by MTX_WEBRTCADDITIONALHOSTS, built
# from MEDIAMTX_PUBLIC_HOSTS (or JVB_ADVERTISE_IPS) in .env, so the server's
# public IP is never hardcoded here.
webrtcAdditionalHosts:
- 127.0.0.1
# Production: add your server's public IP and domain so browsers can reach
# the WebRTC UDP port (8189) from outside Docker. Update these for your deployment.
- 100.56.6.172 # production server IP; keep in sync with JVB_ADVERTISE_IPS
- voxbento.com # public hostname
# Allow the browser JS on :8000 (FastAPI portal) to POST WHEP/WHIP offers
# (cross-origin). Plural form required by MediaMTX ≥ 1.18.
webrtcAllowOrigins: ['*']
Expand Down
20 changes: 18 additions & 2 deletions tests/test_deploy_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ def deployment(tmp_path: Path) -> tuple[Path, Path, str, dict[str, str]]:
executable.chmod(0o755)
workflow = yaml.safe_load(WORKFLOW.read_text())
script = workflow["jobs"]["deploy"]["steps"][1]["with"]["script"]
assert "cd /home/ubuntu/voxbento" in script
script = script.replace("cd /home/ubuntu/voxbento", f"cd {shlex.quote(str(live))}")
old_cd = 'cd "${VOXBENTO_DIR:-$HOME/voxbento}"'
assert old_cd in script
script = script.replace(old_cd, f"cd {shlex.quote(str(live))}")
env = {
"HOME": str(tmp_path),
"PATH": f"{binaries}:{os.environ['PATH']}",
Expand Down Expand Up @@ -174,3 +175,18 @@ def test_portal_uses_image_code_and_keeps_persistent_data() -> None:
assert portal["volumes"] == ["portal-data:/data", "supertonic-cache:/root/.cache"]
assert portal["env_file"] == [{"path": ".env", "required": False}]
assert ".env" in (ROOT / ".dockerignore").read_text().splitlines()


def test_mediamtx_public_hosts_come_from_env_not_a_hardcoded_ip() -> None:
compose = (ROOT / "docker-compose.yml").read_text()
assert "MTX_WEBRTCADDITIONALHOSTS" in compose
assert "${MEDIAMTX_PUBLIC_HOSTS:-${JVB_ADVERTISE_IPS:-127.0.0.1}}" in compose
mediamtx = (ROOT / "mediamtx.yml").read_text()
assert "100.56.6.172" not in mediamtx


def test_deploy_uses_home_directory_and_prunes_only_this_project() -> None:
script = yaml.safe_load(WORKFLOW.read_text())["jobs"]["deploy"]["steps"][1]["with"]["script"]
assert "/home/ubuntu" not in script
assert 'cd "${VOXBENTO_DIR:-$HOME/voxbento}"' in script
assert "docker image prune -f --filter label=com.docker.compose.project=voxbento" in script
10 changes: 9 additions & 1 deletion website/docs/configuration/deployment.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ If `mediamtx_ok` is `false`, the portal is running but MediaMTX is not reachable
Database migrations run automatically on container startup. You do not need to run any migration commands manually when using Docker Compose.
:::

## Public IP for WebRTC media

MediaMTX advertises the server's public IP to browsers for UDP port 8189. Set
`JVB_ADVERTISE_IPS` in `.env` to that IP; MediaMTX uses it too. To advertise different
hosts, set `MEDIAMTX_PUBLIC_HOSTS` (comma-separated). No IP is hardcoded in `mediamtx.yml`.

## Deployment preflight

The production GitHub Actions workflow builds candidate images in a temporary Git
Expand All @@ -153,7 +159,9 @@ secret is missing or unsafe, the deployment stops and the existing stack remains
running. Old images are retained until the replacement portal passes `/healthz`,
then dangling images are pruned. The temporary worktree is removed on exit.
Compose always uses the `voxbento` project name to retain existing volumes and
networks. The portal runs source and dependencies from its image, with `.env`
networks. Only this project's images are pruned, so other Docker projects on the
host are untouched. The deployment directory is `$HOME/voxbento`; set `VOXBENTO_DIR`
in the workflow environment to use another path. The portal runs source and dependencies from its image, with `.env`
loaded as container environment variables; rebuild the image to apply code changes.

Caddy imports optional, host-owned route snippets from
Expand Down