version: "3.9"
services:
  iptv_restream_frontend:
    build:
      context: ../frontend
      dockerfile: Dockerfile
      args:
        # Set this to the server ip/domain, if your backend is deployed on a different server
        #VITE_BACKEND_URL: http://123.123.123.123:5000
        VITE_STREAM_DELAY: 18
        VITE_STREAM_PROXY_DELAY: 30
        # Optional settings for synchronization
        #VITE_SYNCHRONIZATION_TOLERANCE: 0.8
        #VITE_SYNCHRONIZATION_MAX_DEVIATION: 4
        #VITE_SYNCHRONIZATION_ADJUSTMENT: 0.06
        #VITE_SYNCHRONIZATION_MAX_ADJUSTMENT: 0.16
    networks:
      - app-network

  iptv_restream_backend:
    build:
      context: ../backend
      dockerfile: Dockerfile
    restart: unless-stopped
    volumes:
      - streams_data:/streams
      - channels:/channels
    environment:
      STORAGE_PATH: /streams/
      # If you have problems with the playlist, set the backend url manually here
      #BACKEND_URL: http://localhost:5000
    networks:
      - app-network

  # Nginx Reverse Proxy
  iptv_restream_nginx:
    image: nginx:alpine
    volumes:
      - ./nginx/nginx.conf:/etc/nginx/nginx.conf
      - streams_data:/streams
    networks:
      - app-network

  nginx-proxy-manager:
    image: 'jc21/nginx-proxy-manager:latest'
    restart: unless-stopped
    ports:
      - '80:80'
      - '443:443'
      - '81:81'
      # Nginx Proxy Manager Web - '81:81'
    volumes:
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt
    networks:
      - app-network

# Volumes
volumes:
  streams_data:
    driver: local
    driver_opts:
      type: tmpfs
      device: tmpfs
  channels:

# Internal docker network
networks:
  app-network:
    driver: bridge