services:
  jellyfin:
    restart: unless-stopped
    image: jellyfin/jellyfin:latest
    devices:
      - /dev/dri:/dev/dri
    volumes:
      - /home/docker/DenFlix/config:/config
      - /home/docker/DenFlix/cache:/cache
      - /mnt/bindmounts/multimedia:/multimedia
      - /tmp/jellyfin/transcodes:/transcodes
    environment:
      - JELLYFIN_PublishedServerUrl=https://jelly.luckyden.org
      - TZ=Europe/Paris
      - DOCKER_MODS=lizardbyte/themerr-jellyfin:latest

    extra_hosts:
      - host.docker.internal:host-gateway
    networks:
      tan-network:
        ipv4_address: 10.10.0.60
    labels:
      - traefik.enable=true
      - traefik.http.routers.jellyfin.rule=Host(`jelly.luckyden.org`)
      - traefik.http.routers.jellyfin.entrypoints=websecure
      - traefik.http.routers.jellyfin.tls.certresolver=cloudflare
      - traefik.http.services.jellyfin.loadbalancer.server.port=8096

  tracearr:
    image: ghcr.io/connorgallopo/tracearr:latest
    environment:
      - NODE_ENV=production
      - PORT=3000
      - HOST=0.0.0.0
      - TZ=Europe/Paris
      - DATABASE_URL=postgres://tracearr:${DB_PASSWORD}@timescale:5432/tracearr
      - REDIS_URL=redis://redis:6379
      - JWT_SECRET=${JWT_SECRET}
      - COOKIE_SECRET=${COOKIE_SECRET}
      - CORS_ORIGIN=*
      - LOG_LEVEL=info
      - TRUSTED_PROXIES=10.10.0.20
    depends_on:
      timescale:
        condition: service_healthy
      redis:
        condition: service_healthy
    restart: unless-stopped
    networks:
      tan-network:
        ipv4_address: 10.10.0.61
    labels:
      - traefik.enable=true
      - traefik.http.routers.tracearr.rule=Host(`tracearr.luckyden.org`)
      - traefik.http.routers.tracearr.entrypoints=websecure
      - traefik.http.routers.tracearr.tls.certresolver=cloudflare
      - traefik.http.services.tracearr.loadbalancer.server.port=3000

  timescale:
    image: timescale/timescaledb:2.25.0-pg16
    shm_size: 512mb
    ulimits:
      nofile:
        soft: 65536
        hard: 65536
    command: postgres -c timescaledb.max_tuples_decompressed_per_dml_transaction=0 -c max_locks_per_transaction=4096 -c timescaledb.telemetry_level=off
    environment:
      - POSTGRES_USER=tracearr
      - POSTGRES_PASSWORD=${DB_PASSWORD}
      - POSTGRES_DB=tracearr
    volumes:
      - /home/docker/MoniDen/timescale_data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U tracearr"]
      interval: 10s
      timeout: 5s
      retries: 5
    restart: unless-stopped
    networks:
      tan-network:
        ipv4_address: 10.10.0.62

  redis:
    image: redis:8-alpine
    command: redis-server --appendonly yes
    volumes:
      - /home/docker/MoniDen/redis_data:/data
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 10s
      timeout: 5s
      retries: 5
    restart: unless-stopped
    networks:
      tan-network:
        ipv4_address: 10.10.0.63

networks:
  tan-network:
    external: true
