diff --git a/hosts/chelsty-infra/runtime/frigate/config.yml b/hosts/chelsty-infra/runtime/frigate/config.yml new file mode 100644 index 0000000..4a98f7d --- /dev/null +++ b/hosts/chelsty-infra/runtime/frigate/config.yml @@ -0,0 +1,88 @@ +# Frigate NVR — chelsty-infra +# Hardware decode: Intel UHD 630 via VAAPI (/dev/dri/renderD128) +# Object detection: CPU (no Coral TPU) +# Cameras: 2x Reolink RLC-540 (5MP, WiFi) +# +# Required env vars in /opt/homelab/config/frigate/frigate.env: +# CAMERA1_IP, CAMERA1_USER, CAMERA1_PASS +# CAMERA2_IP, CAMERA2_USER, CAMERA2_PASS +# MQTT_USER, MQTT_PASS (if mosquitto auth is enabled) + +mqtt: + enabled: true + host: 127.0.0.1 + port: 1883 + # user: "{MQTT_USER}" + # password: "{MQTT_PASS}" + +detectors: + cpu1: + type: cpu + num_threads: 3 + +ffmpeg: + hwaccel_args: preset-vaapi + global_args: + - -hide_banner + - -loglevel + - warning + +record: + enabled: true + retain: + days: 7 + mode: all + events: + retain: + default: 14 + mode: motion + +snapshots: + enabled: true + retain: + default: 7 + quality: 70 + +objects: + track: + - person + - car + - bicycle + filters: + person: + min_area: 5000 + max_area: 100000 + threshold: 0.7 + +cameras: + camera1: + ffmpeg: + inputs: + # Main stream — high-res recording + - path: rtsp://{CAMERA1_USER}:{CAMERA1_PASS}@{CAMERA1_IP}:554/h264Preview_01_main + roles: + - record + # Sub stream — low-res detection (lower CPU cost) + - path: rtsp://{CAMERA1_USER}:{CAMERA1_PASS}@{CAMERA1_IP}:554/h264Preview_01_sub + roles: + - detect + detect: + enabled: true + width: 640 + height: 480 + fps: 5 + + camera2: + ffmpeg: + inputs: + - path: rtsp://{CAMERA2_USER}:{CAMERA2_PASS}@{CAMERA2_IP}:554/h264Preview_01_main + roles: + - record + - path: rtsp://{CAMERA2_USER}:{CAMERA2_PASS}@{CAMERA2_IP}:554/h264Preview_01_sub + roles: + - detect + detect: + enabled: true + width: 640 + height: 480 + fps: 5 diff --git a/hosts/chelsty-infra/runtime/frigate/docker-compose.yml b/hosts/chelsty-infra/runtime/frigate/docker-compose.yml new file mode 100644 index 0000000..308474e --- /dev/null +++ b/hosts/chelsty-infra/runtime/frigate/docker-compose.yml @@ -0,0 +1,24 @@ +services: + frigate: + container_name: frigate + image: ghcr.io/blakeblackshear/frigate:stable + restart: unless-stopped + privileged: true + shm_size: "256mb" + network_mode: host + devices: + - /dev/dri/renderD128:/dev/dri/renderD128 + volumes: + - /etc/localtime:/etc/localtime:ro + - ./config.yml:/config/config.yml:ro + - /opt/homelab/data/frigate:/media/frigate + tmpfs: + - /tmp/cache + env_file: + - /opt/homelab/config/frigate/frigate.env + healthcheck: + test: ["CMD-SHELL", "wget -q --spider http://localhost:5000/api/version 2>&1 || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 60s diff --git a/hosts/chelsty-infra/services.yaml b/hosts/chelsty-infra/services.yaml index f6fe5f5..475f8df 100644 --- a/hosts/chelsty-infra/services.yaml +++ b/hosts/chelsty-infra/services.yaml @@ -8,3 +8,5 @@ services: role: zigbee-mqtt-bridge stability-agent: role: node-stability-monitor + frigate: + role: nvr diff --git a/scripts/deploy/deploy-frigate.sh b/scripts/deploy/deploy-frigate.sh new file mode 100755 index 0000000..fe1e8c7 --- /dev/null +++ b/scripts/deploy/deploy-frigate.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +# deploy-frigate.sh - Deploy Frigate NVR on chelsty-infra (print or SSH) + +MODE="print" +[[ "$1" == "--ssh" ]] && MODE="ssh" + +TARGET="100.122.201.22" +NODE="chelsty-infra" +REPO_PATH="/home/oskar/homelab-codex-ws" +SERVICE_PATH="$REPO_PATH/hosts/chelsty-infra/runtime/frigate" + +echo "HOST: $NODE" +echo "MODE: $MODE" +echo "TARGET: $TARGET" + +# Secrets must exist at /opt/homelab/config/frigate/frigate.env on the node +# before first deploy. See config.yml for required variables. +DEPLOY_CMD="cd $REPO_PATH && git fetch origin && git checkout master && git pull origin master && cd $SERVICE_PATH && docker compose up -d --pull always" + +if [[ "$MODE" == "ssh" ]]; then + echo "--- Deploying Frigate to $NODE ($TARGET) via SSH ---" + ssh oskar@$TARGET "$DEPLOY_CMD" +else + echo "# --- Deployment commands for $NODE ---" + echo "ssh oskar@$TARGET '$DEPLOY_CMD'" +fi