Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.
fix(install): keep LiveKit port selection in local Compose config
Dongdong Chen3d394a912a24
diff --git a/.env.example b/.env.exampleindex db21a39e..aa2902c8 100644--- a/.env.example+++ b/.env.example@@ -130,10 +130,6 @@ VOICE_RUNTIME_XAI_LIVE_AUDIO_TRANSPORT=binaryLIVEKIT_URL=ws://127.0.0.1:17880LIVEKIT_API_KEY=devkeyLIVEKIT_API_SECRET=devsecret-livekit-voice-local-only-32-bytes-# Compose ports. RTC ports must match the ports LiveKit advertises to browsers.-LIVEKIT_HTTP_PORT=17880-LIVEKIT_RTC_TCP_PORT=7881-LIVEKIT_RTC_UDP_PORT=7882# The root docker-compose.yml LiveKit serves this computer only. A host that# serves browsers on other computers sets the address they reach it on,# publishes the media ports (TCP 7881, UDP 7882) on every interface, and setsdiff --git a/README.md b/README.mdindex df0df5b8..e1027a5a 100644--- a/README.md+++ b/README.md@@ -207,9 +207,10 @@ approval, and connects `linger-computer` to your Linger server. Run`--remove`), or see [Bring your own runtime](docs/local-inference.md) for othermodel setups.-If Compose ports are busy, the installer offers to save free ports in `.env`.-LiveKit uses the selected RTC ports both inside its container and on the host,-so browsers connect to the ports it advertises.+If Compose ports are busy, the installer offers to select free ports. It saves+LiveKit's port mappings and matching RTC configuration in+`.local/compose.ports.yml` and enables the override through `.env`. Rerunning the+installer reuses those ports.## Learn morediff --git a/docker-compose.yml b/docker-compose.ymlindex 28802c44..acf1267b 100644--- a/docker-compose.yml+++ b/docker-compose.yml@@ -57,8 +57,8 @@ services:- |port: 7880rtc:- tcp_port: ${LIVEKIT_RTC_TCP_PORT:-7881}- udp_port: ${LIVEKIT_RTC_UDP_PORT:-7882}+ tcp_port: 7881+ udp_port: 7882use_external_ip: falselogging:level: info@@ -71,9 +71,9 @@ services:# ports with LIVEKIT_RTC_BIND_ADDRESS.NODE_IP: "${LIVEKIT_NODE_IP:-127.0.0.1}"ports:- - "127.0.0.1:${LIVEKIT_HTTP_PORT:-17880}:7880"- - "${LIVEKIT_RTC_BIND_ADDRESS:-127.0.0.1}:${LIVEKIT_RTC_TCP_PORT:-7881}:${LIVEKIT_RTC_TCP_PORT:-7881}"- - "${LIVEKIT_RTC_BIND_ADDRESS:-127.0.0.1}:${LIVEKIT_RTC_UDP_PORT:-7882}:${LIVEKIT_RTC_UDP_PORT:-7882}/udp"+ - "127.0.0.1:17880:7880"+ - "${LIVEKIT_RTC_BIND_ADDRESS:-127.0.0.1}:7881:7881"+ - "${LIVEKIT_RTC_BIND_ADDRESS:-127.0.0.1}:7882:7882/udp"healthcheck:test: ["CMD", "wget", "-q", "-O", "-", "http://127.0.0.1:7880/"]interval: 3sdiff --git a/scripts/env-inventory.json b/scripts/env-inventory.jsonindex 455b4a17..399142b2 100644--- a/scripts/env-inventory.json+++ b/scripts/env-inventory.json@@ -9,9 +9,6 @@"WEB_BIND_ADDRESS": "docker compose host-address interpolation of the Web port in the root docker-compose.yml (pnpm stack:up)","NODE_SERVICES_HTTP_PORT": "docker compose host-port interpolation in the root docker-compose.yml (pnpm stack:up)","DOCUMENT_RUNTIME_HTTP_PORT": "docker compose host-port interpolation in the root docker-compose.yml (pnpm stack:up)",- "LIVEKIT_HTTP_PORT": "docker compose host-port interpolation of the LiveKit HTTP endpoint in the root docker-compose.yml",- "LIVEKIT_RTC_TCP_PORT": "docker compose interpolation of both the published TCP port and LiveKit RTC TCP listener in the root docker-compose.yml",- "LIVEKIT_RTC_UDP_PORT": "docker compose interpolation of both the published UDP port and LiveKit RTC UDP listener in the root docker-compose.yml","LIVEKIT_NODE_IP": "docker compose interpolation of the LiveKit advertised media address (NODE_IP) in the root docker-compose.yml","LIVEKIT_RTC_BIND_ADDRESS": "docker compose host-address interpolation of the LiveKit media ports in the root docker-compose.yml"},diff --git a/scripts/install.test.ts b/scripts/install.test.tsindex 184f0b74..fc96dfab 100644--- a/scripts/install.test.ts+++ b/scripts/install.test.ts@@ -867,14 +867,26 @@ esacexpect(updatedEnv).toContain("WEB_HTTP_PORT=3001");expect(updatedEnv).toContain("WEB_PUBLIC_ORIGIN=http://localhost:3001");expect(updatedEnv).toContain("LIVEKIT_URL=ws://127.0.0.1:17881");- expect(updatedEnv).toContain("LIVEKIT_HTTP_PORT=17881");- expect(updatedEnv).toContain("LIVEKIT_RTC_TCP_PORT=7883");- expect(updatedEnv).toContain("LIVEKIT_RTC_UDP_PORT=7884");- expect(updatedEnv).not.toContain("COMPOSE_FILE=");+ expect(updatedEnv).not.toMatch(+ /^LIVEKIT_(HTTP_PORT|RTC_TCP_PORT|RTC_UDP_PORT)=/m,+ );+ expect(updatedEnv).toContain(+ "COMPOSE_FILE=docker-compose.yml:.local/compose.ports.yml",+ );expect(updatedEnv).not.toContain("POSTGRES_PORT=5433");- await expect(- stat(path.join(fakeRepo, ".local/compose.ports.yml")),- ).rejects.toMatchObject({ code: "ENOENT" });+ const overridePath = path.join(fakeRepo, ".local/compose.ports.yml");+ const override = await readFile(overridePath, "utf8");+ expect(override).toContain("tcp_port: 7883");+ expect(override).toContain("udp_port: 7884");+ expect(override).toContain("use_external_ip: false");+ expect(override).toContain("ports: !override");+ expect(override).toContain('"127.0.0.1:17881:7880"');+ expect(override).toContain(+ '"${LIVEKIT_RTC_BIND_ADDRESS:-127.0.0.1}:7883:7883"',+ );+ expect(override).toContain(+ '"${LIVEKIT_RTC_BIND_ADDRESS:-127.0.0.1}:7884:7884/udp"',+ );const dockerCalls = await readFile(dockerLogPath, "utf8");expect(dockerCalls).toContain("compose up --build --detach --wait");@@ -895,6 +907,7 @@ esacexpect(await readFile(path.join(fakeRepo, ".env"), "utf8")).toBe(updatedEnv,);+ expect(await readFile(overridePath, "utf8")).toBe(override);});it("validates CLI flags, conflicting modes, and standalone menu outside repo", async () => {diff --git a/scripts/install/install.sh b/scripts/install/install.shindex 055cd34e..13b2cf6f 100755--- a/scripts/install/install.sh+++ b/scripts/install/install.sh@@ -426,6 +426,21 @@ collect_docker_host_ports() {tr ', ' '\n' | sed -nE 's/.*:([0-9]+)->[0-9]+\/(tcp|udp).*/\1\/\2/p' | sort -u}+read_livekit_override_port() {+ local file="$1"+ local key="$2"+ local fallback="$3"+ local port=""+ if [[ -f "$file" ]]; then+ if [[ "$key" == "http" ]]; then+ port="$(sed -nE 's/.*:([0-9]+):7880"[[:space:]]*$/\1/p' "$file")"+ else+ port="$(sed -nE "s/^[[:space:]]*${key}:[[:space:]]*([0-9]+)[[:space:]]*$/\1/p" "$file")"+ fi+ fi+ printf '%s\n' "${port:-$fallback}"+}+is_port_busy() {local port="$1"local proto="$2"@@ -489,6 +504,7 @@ pick_free_port() {ensure_compose_ports() {local env_file="$REPO_ROOT/.env"+ local override_file="$REPO_ROOT/.local/compose.ports.yml"local own_raw=""own_raw="$(cd "$REPO_ROOT" && docker compose ps --format '{{.Ports}}' 2>/dev/null || true)"@@ -513,9 +529,9 @@ ensure_compose_ports() {cur_node="$(read_env_value "$env_file" "NODE_SERVICES_HTTP_PORT" || printf '4319')"cur_doc="$(read_env_value "$env_file" "DOCUMENT_RUNTIME_HTTP_PORT" || printf '4321')"cur_lk_url="$(read_env_value "$env_file" "LIVEKIT_URL" || printf 'ws://127.0.0.1:17880')"- cur_lk_http="$(read_env_value "$env_file" "LIVEKIT_HTTP_PORT" || printf '17880')"- cur_lk_tcp="$(read_env_value "$env_file" "LIVEKIT_RTC_TCP_PORT" || printf '7881')"- cur_lk_udp="$(read_env_value "$env_file" "LIVEKIT_RTC_UDP_PORT" || printf '7882')"+ cur_lk_http="$(read_livekit_override_port "$override_file" "http" "17880")"+ cur_lk_tcp="$(read_livekit_override_port "$override_file" "tcp_port" "7881")"+ cur_lk_udp="$(read_livekit_override_port "$override_file" "udp_port" "7882")"local reserved=" $cur_pg $cur_th $cur_web $cur_node $cur_doc $cur_lk_http $cur_lk_tcp $cur_lk_udp "local new_pg="$cur_pg"@@ -644,16 +660,35 @@ ensure_compose_ports() {fiif [[ "$new_lk_http" != "$cur_lk_http" ]]; then- set_env_value "$env_file" "LIVEKIT_HTTP_PORT" "$new_lk_http"if [[ -z "$cur_lk_url" || "$cur_lk_url" =~ ^ws://(127\.0\.0\.1|localhost): ]]; thenset_env_value "$env_file" "LIVEKIT_URL" "ws://127.0.0.1:$new_lk_http"fifi- if [[ "$new_lk_tcp" != "$cur_lk_tcp" ]]; then- set_env_value "$env_file" "LIVEKIT_RTC_TCP_PORT" "$new_lk_tcp"- fi- if [[ "$new_lk_udp" != "$cur_lk_udp" ]]; then- set_env_value "$env_file" "LIVEKIT_RTC_UDP_PORT" "$new_lk_udp"+ if [[ "$new_lk_http" != "$cur_lk_http" || "$new_lk_tcp" != "$cur_lk_tcp" || "$new_lk_udp" != "$cur_lk_udp" ]]; then+ mkdir -p "$(dirname "$override_file")"+ cat > "$override_file" <<EOF+services:+ livekit:+ command:+ - --config-body+ - |+ port: 7880+ rtc:+ tcp_port: $new_lk_tcp+ udp_port: $new_lk_udp+ use_external_ip: false+ logging:+ level: info+ ports: !override+ - "127.0.0.1:$new_lk_http:7880"+ - "\${LIVEKIT_RTC_BIND_ADDRESS:-127.0.0.1}:$new_lk_tcp:$new_lk_tcp"+ - "\${LIVEKIT_RTC_BIND_ADDRESS:-127.0.0.1}:$new_lk_udp:$new_lk_udp/udp"+EOF+ local compose_files=""+ compose_files="$(read_env_value "$env_file" "COMPOSE_FILE" || printf 'docker-compose.yml')"+ if [[ ":$compose_files:" != *":.local/compose.ports.yml:"* ]]; then+ set_env_value "$env_file" "COMPOSE_FILE" "$compose_files:.local/compose.ports.yml"+ fifi}