From 1dd8802c682114620a8c6cec4daf3a244572fd6b Mon Sep 17 00:00:00 2001 From: xEsiah Date: Sun, 25 Oct 2026 15:05:42 +0100 Subject: [PATCH] fix: add GO2RTC_PUBLIC_URL environment variable --- .github/workflows/deploy.yml | 4 +- apps/kai-sa-cam/src/App.tsx | 94 +++++++++++++++++++----------------- docker-compose.yml | 6 ++- 3 files changed, 56 insertions(+), 48 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2d50066..8dcdee0 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -29,5 +29,5 @@ jobs: cd "$dir" git pull --ff-only origin main docker compose --profile prod build - docker compose --profile prod up -d - docker image prune -f \ No newline at end of file + docker compose --profile prod up -d --force-recreate kai-sa-go2rtc kai-sa-cam + docker image prune -f diff --git a/apps/kai-sa-cam/src/App.tsx b/apps/kai-sa-cam/src/App.tsx index 8087b63..8a84daa 100644 --- a/apps/kai-sa-cam/src/App.tsx +++ b/apps/kai-sa-cam/src/App.tsx @@ -1,54 +1,64 @@ -import { useState, useEffect, useRef } from 'react' -import { VideoPlayer } from './components/VideoPlayer' -import { Controls } from './components/Controls' -import { MediaGallery } from './components/MediaGallery' -import { useRecorder } from './hooks/useRecorder' -import { useTalk } from './hooks/useTalk' +import { useState, useEffect, useRef } from "react"; +import { VideoPlayer } from "./components/VideoPlayer"; +import { Controls } from "./components/Controls"; +import { MediaGallery } from "./components/MediaGallery"; +import { useRecorder } from "./hooks/useRecorder"; +import { useTalk } from "./hooks/useTalk"; export function App() { - const [activeTab, setActiveTab] = useState<'live' | 'media'>('live') - const [isRecording, setIsRecording] = useState(false) - const [isTalking, setIsTalking] = useState(false) - const [gain, setGain] = useState(1) - const [recordingTime, setRecordingTime] = useState(0) - const [snapshots, setSnapshots] = useState([]) + const [activeTab, setActiveTab] = useState<"live" | "media">("live"); + const [isRecording, setIsRecording] = useState(false); + const [isTalking, setIsTalking] = useState(false); + const [gain, setGain] = useState(1); + const [recordingTime, setRecordingTime] = useState(0); + const [snapshots, setSnapshots] = useState([]); - const { startRecording, stopRecording, error: recError } = useRecorder({ - onStart: () => { setIsRecording(true); setRecordingTime(0) }, - onStop: () => { setIsRecording(false); setRecordingTime(0) }, + const { + startRecording, + stopRecording, + error: recError, + } = useRecorder({ + onStart: () => { + setIsRecording(true); + setRecordingTime(0); + }, + onStop: () => { + setIsRecording(false); + setRecordingTime(0); + }, onTimeUpdate: (t) => setRecordingTime(t), - }) + }); - const { startTalk, stopTalk, error: talkError } = useTalk({ gain }) + const { startTalk, stopTalk, error: talkError } = useTalk({ gain }); const handleRecord = async () => { if (isRecording) { - await stopRecording() + await stopRecording(); } else { - await startRecording() + await startRecording(); } - } + }; const handleSnapshot = async () => { try { - const res = await fetch('/api/media/snapshots', { method: 'POST' }) - if (!res.ok) throw new Error('Snapshot failed') - const data = await res.json() - setSnapshots(prev => [data.filename, ...prev]) + const res = await fetch("/api/media/snapshots", { method: "POST" }); + if (!res.ok) throw new Error("Snapshot failed"); + const data = await res.json(); + setSnapshots((prev) => [data.filename, ...prev]); } catch (e) { - console.error('Snapshot error:', e) + console.error("Snapshot error:", e); } - } + }; const handleTalk = async () => { if (isTalking) { - stopTalk() - setIsTalking(false) + stopTalk(); + setIsTalking(false); } else { - await startTalk() - setIsTalking(true) + await startTalk(); + setIsTalking(true); } - } + }; return (
@@ -73,24 +83,22 @@ export function App() {
- {activeTab === 'live' && ( + {activeTab === "live" && (
- + )} - {activeTab === 'media' && ( - - )} + {activeTab === "media" && }
- ) -} \ No newline at end of file + ); +} diff --git a/docker-compose.yml b/docker-compose.yml index 5ece73b..92b9567 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,6 +13,7 @@ services: - ./config/kai-sa-go2rtc.yaml:/config/go2rtc.yaml:ro networks: - kai-sa-cam-internal + - kai-sa-cam-tunnel cap_drop: - ALL security_opt: @@ -40,8 +41,9 @@ services: - MAX_RECORDING_MINUTES=${MAX_RECORDING_MINUTES:-120} - DISK_MIN_FREE_GB=${DISK_MIN_FREE_GB:-2} - GO2RTC_URL=http://kai-sa-go2rtc:1984 + - GO2RTC_PUBLIC_URL=https://stream.esiah.dev - GO2RTC_RTSP_URL=rtsp://kai-sa-go2rtc:8554/webcam - - PULSE_SERVER=unix:/run/user/1001/pulse/native + - PULSE_SERVER=${PULSE_SERVER} - XDG_RUNTIME_DIR=/run/user/1001 volumes: - ./media:/media @@ -65,4 +67,4 @@ networks: internal: true kai-sa-cam-tunnel: external: true - name: kai-sa-cam-tunnel \ No newline at end of file + name: kai-sa-cam-tunnel