runner

Ansible role that deployes services on my runner machine

2.3 KBJ2
frigate-compose.yml.j2
2.3 KB95 lines • plaintext
1services:
2  frigate:
3    container_name: frigate
4{% if frigate_hardware_acceleration == 'nvenc' %}
5    image: ghcr.io/blakeblackshear/frigate:stable-tensorrt 
6{% else %}
7    image: ghcr.io/blakeblackshear/frigate:stable
8{% endif %}
9    restart: unless-stopped
10    privileged: true
11    
12    shm_size: "1gb"
13    env_file:
14      - frigate.env
15    
16    volumes:
17      # Configuration (read-write for dynamic config updates)
18      - {{ frigate_config_dir }}/config:/config
19      
20      # Local storage for database and models
21      - {{ frigate_config_dir }}/data:/data
22      
23      # NFS storage for recordings
24      - {{ frigate_data_dir }}:/media/frigate
25      
26      # Temporary memory storage for clips
27      - type: tmpfs
28        target: /tmp/cache
29        tmpfs:
30          size: 1000000000  # 1GB
31    
32    ports:
33      - "{{ frigate_port }}:5000"      # Web UI
34      - "{{ frigate_rtmp_port }}:1935" # RTMP
35      - "{{ frigate_rtsp_port }}:8554" # RTSP Re-stream
36      - "{{ frigate_go2rtc_port }}:1984"
37    
38{% if frigate_hardware_acceleration == 'nvenc' %}
39    runtime: nvidia
40    environment:
41      - NVIDIA_VISIBLE_DEVICES=all
42      - NVIDIA_DRIVER_CAPABILITIES=all
43      - ORT_TENSORRT_ENGINE_CACHE_ENABLE=1
44      - ORT_TENSORRT_FP16_ENABLE=1
45      - ORT_TENSORRT_ENGINE_CACHE_PATH=/data/model_cache
46
47    devices:
48      - /dev/dri:/dev/dri
49{% endif %}
50
51    networks:
52      frigate_net:
53        aliases:
54          - frigate
55
56  frigate-snapshots:
57    build:
58      context: .
59      dockerfile: Dockerfile
60    container_name: frigate-snapshots
61    restart: unless-stopped
62    environment:
63      - TZ=Europe/Amsterdam
64
65      - FRIGATE_BASE_URL=http://frigate:5000
66      - CAMERAS=living-room,dining-room,bed-room,alina-office
67
68      # MQTT broker params
69      - MQTT_HOST={{ frigate_mqtt_host }}
70      - MQTT_PORT={{ frigate_mqtt_port }}
71      - MQTT_USER={{ frigate_mqtt_username }}
72      - MQTT_PASS={{ frigate_mqtt_password }}
73
74    volumes:
75      - ./snapshot-data/snapshots:/snapshots
76      - ./snapshot-data/snapshot.sh:/opt/snapshot.sh
77
78    command:
79      - /bin/sh
80      - -lc
81      - |
82        set -eu
83        chmod +x /opt/snapshot.sh
84        mkdir -p /etc/crontabs
85        echo "$CRON_SCHEDULE /opt/snapshot.sh >> /var/log/cron.log 2>&1" > /etc/crontabs/root
86        crond -f -L /var/log/cron.log
87
88    networks:
89      - frigate_net
90
91networks:
92  frigate_net:
93    driver: bridge
94
95