networks:
  net:
    external: false

services:
  haproxy:
    image: haproxy:lts
    container_name: haproxy
    env_file:
       - "variables.env"
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - "./data/certificates:/certificates"
      - "./config/haproxy:/usr/local/etc/haproxy"
    depends_on:
      - "restreamer"
      - "api"
    restart: unless-stopped
    networks:
      - net
    labels:
      - meta.role=haproxy

  acme-sh:
    image: neilpang/acme.sh
    container_name: acme.sh
    volumes:
      - "./data/acme:/acme.sh"
      - "./data/certificates:/certificates"
    network_mode: host
    command: daemon
    stdin_open: true
    tty: true
    restart: "no"

  restreamer:
    image: datarhei/restreamer:2.12.0
    env_file:
       - "variables.env"
    ports:
      - "6000:6000/udp"
    volumes:
      - "./data/restreamer/config:/core/config"
      - "./data/restreamer/data:/core/data"
    restart: unless-stopped
    networks:
      - net
    labels:
      - meta.role=restreamer

  api:
    depends_on:
      - "restreamer"
    build: ./src/api
    image: tv-api:latest
    env_file:
      - "variables.env"
    volumes:
      - "./config/api:/config"
      - "./data/recorder:/recordings"
    restart: unless-stopped
    networks:
      - net
    labels:
      - meta.role=api

  discordbot:
    depends_on:
      - "api"
    build: ./src/discordbot
    image: tv-discordbot:latest
    env_file:
      - "variables.env"
    volumes:
      - "./data/recorder:/recordings"
    restart: unless-stopped
    networks:
      - net
    labels:
      - meta.role=discordbot

  icecast:
    depends_on:
      - "api"
    build: ./src/icecast
    image: tv-icecast:latest
    env_file:
      - "variables.env"
    restart: unless-stopped
    ports:
      - "8000:8000"
    volumes:
      - /etc/localtime:/etc/localtime:ro 
      - "./config/icecast/icecast.xml.template:/etc/icecast2/icecast.xml.template"
      - "./data/icecast:/usr/share/icecast2/web/data"
      - "./logs/icecast:/var/log/icecast2"
    networks:
      - net
    labels:
      - meta.role=icecast
