72 lines
2.3 KiB
Plaintext
72 lines
2.3 KiB
Plaintext
{ config, pkgs, ... }:
|
|
|
|
let
|
|
container_name = "frigate";
|
|
compose-dir = "docker-compose/frigate";
|
|
config-dir = "/mnt/config-storage/docker-data/frigate";
|
|
data-dir = "/mnt/data-storage/docker-data/frigate";
|
|
in
|
|
|
|
{
|
|
config = {
|
|
environment.etc."${compose-dir}/compose.yaml".text =
|
|
/*
|
|
yaml
|
|
*/
|
|
''
|
|
services:
|
|
frigate:
|
|
image: ghcr.io/blakeblackshear/frigate:stable
|
|
container_name: frigate
|
|
shm_size: "512MB"
|
|
networks:
|
|
hass_frontend:
|
|
hass_backend:
|
|
volumes:
|
|
- ${config-dir}/config:/config
|
|
- ${data-dir}/clips:/media/frigate/clips
|
|
- ${data-dir}/recordings:/media/frigate/recordings
|
|
- ${data-dir}/exports:/media/frigate/exports
|
|
- /etc/localtime:/etc/localtime:ro
|
|
- type: tmpfs
|
|
target: /tmp/cache
|
|
tmpfs:
|
|
size: 2000000000
|
|
environment:
|
|
FRIGATE_MQTT_USER: $FRIGATE_MQTT_USER
|
|
FRIGATE_MQTT_PASSWORD: $FRIGATE_MQTT_PASSWORD
|
|
# --- frigate devices --- #
|
|
labels:
|
|
- traefik.enable=true
|
|
- traefik.http.routers.frigate-https.tls=true
|
|
- traefik.http.routers.frigate-https.tls.certresolver=cloudflare
|
|
restart: unless-stopped
|
|
|
|
networks:
|
|
hass_backend:
|
|
external: true
|
|
hass_frontend:
|
|
external: true
|
|
'';
|
|
|
|
systemd.services.frigate = {
|
|
description = "Docker container : ${container_name}";
|
|
after = [ "network.target" "docker.service" "docker.socket" "traefik.service" ];
|
|
requires = [ "docker.service" ];
|
|
wantedBy = ["multi-user.target"];
|
|
path = [ pkgs.docker ];
|
|
|
|
serviceConfig = {
|
|
Type = "exec";
|
|
# Pull the latest image before running
|
|
ExecStartPre = "${pkgs.docker}/bin/docker compose -f /etc/${compose-dir}/compose.yaml pull";
|
|
# Bring the service up
|
|
ExecStart = "${pkgs.docker}/bin/docker compose -f /etc/${compose-dir}/compose.yaml up --remove-orphans";
|
|
# Take it down gracefully
|
|
ExecStop = "${pkgs.docker}/bin/docker compose -f /etc/${compose-dir}/compose.yaml down";
|
|
|
|
Restart = "on-failure";
|
|
};
|
|
};
|
|
};
|
|
} |