version: '2'

services:
  main:
    build: ./docker-liquidsoap
    volumes:
    - ./state/liquidsoap/config:/config
    - ./state/playlists:/playlists
    - ./state/liquidsoap/data:/data
    - ./state/jingles:/jingles
    - /etc/localtime:/etc/localtime:ro 
    command: /bin/bash -xc 'env; liquidsoap -v --debug /config/main.liq'
    environment:
    - HARBOR_PASSWORD=MGT7aEqP
    - LIVE_PASSWORD=fuckyoujoa
    - BROADCAST_PORT_5001_TCP_ADDR=broadcast
    - BROADCAST_PORT_5001_TCP_PORT=5001
    links:
    - icecast
    ports:
    - 8022:5002
    - 127.0.0.1:5000:5000
    restart: on-failure
    
  broadcast:
    build: ./docker-liquidsoap
    volumes:
    - ./state/liquidsoap/config:/config
    - /etc/localtime:/etc/localtime:ro 
    command: /bin/bash -xc 'env; liquidsoap -v --debug /config/broadcast.liq'
    environment:
    - HARBOR_PASSWORD=MGT7aEqP
    - ICECAST_PORT_8000_TCP_ADDR=icecast
    - ICECAST_PORT_8000_TCP_PORT=8000
    - ICECAST_SOURCE_PASSWORD=KUsFNWgh
    links:
    - icecast
    restart: on-failure
  
  icecast:
    image: moul/icecast
    volumes:
      - /etc/localtime:/etc/localtime:ro
    environment:
      - ICECAST_SOURCE_PASSWORD=KUsFNWgh
      - ICECAST_ADMIN_PASSWORD=admin
      - ICECAST_PASSWORD=Bk3H7UM8
      - ICECAST_RELAY_PASSWORD=hackme
    labels:
      - "traefik.enable=true"
      
      - "traefik.http.services.radio-icecast.loadbalancer.server.port=8000"
      - "traefik.http.routers.radio-iceast-http.rule=Host(`iceast.radio.dodsorf.as`)"
      - "traefik.http.routers.radio-icecast-http.middlewares=redirect@file"
      - "traefik.http.routers.radio-icecast-http.entrypoints=web"
      
      - "traefik.http.routers.radio-icecast-https.rule=Host(`icecast.radio.dodsorf.as`)"
      - "traefik.http.routers.radio-icecast-https.tls=true"
      - "traefik.http.routers.radio-icecast-https.tls.certresolver=normal"
      - "traefik.http.routers.radio-icecast-https.entrypoints=websecure"
    networks:
      - reverse
      - default

  web:
    build: ./web
    environment:
    - MAIN_PORT_5000_TCP=tcp://main:5000
    links:
    - main
    volumes:
    - ./state/playlists:/playlists
    labels:
    - "traefik.enable=true"
    
    - "traefik.http.services.radio-web.loadbalancer.server.port=80"
    - "traefik.http.routers.radio-web-http.rule=Host(`radio.dodsorf.as`)"
    - "traefik.http.routers.radio-web-http.middlewares=redirect@file"
    - "traefik.http.routers.radio-web-http.entrypoints=web"
    
    - "traefik.http.routers.radio-web-https.rule=Host(`radio.dodsorf.as`)"
    - "traefik.http.routers.radio-web-https.tls=true"
    - "traefik.http.routers.radio-web-https.entrypoints=websecure"
    - "traefik.http.routers.radio-web-https.tls.certresolver=normal"
    networks:
    - reverse
    - default

networks:
  reverse:
    external:
      name: reverse
