version: "3.4"

services:
  engine-core:
    container_name: engine-core
    build:
      context: .
      dockerfile: Dockerfile
    # image: autoradio/engine-core:${AURA_ENGINE_CORE_VERSION}
    user: "2872:2872"
    group_add:
      - audio
    # devices:
    #   - /dev/snd
    command: ["./entrypoint.sh"]
    environment:
      TZ: ${TIMEZONE}
      AURA_ENGINE_CORE_LOG_LEVEL: ${AURA_ENGINE_CORE_LOG_LEVEL:?value from 1-5}
      AURA_ENGINE_RUN_AS_ROOT: false
      # Audio Device Settings
      AURA_ENGINE_OUTPUT_DEVICE: ${AURA_ENGINE_OUTPUT_DEVICE}
      AURA_ENGINE_INPUT_DEVICE: ${AURA_ENGINE_INPUT_DEVICE}
      # Fallback Settings
      AURA_ENGINE_FALLBACK_SHOW_NAME: ${AURA_ENGINE_FALLBACK_SHOW_NAME}
      AURA_ENGINE_FALLBACK_SHOW_ID: ${AURA_ENGINE_FALLBACK_SHOW_ID}
      AURA_ENGINE_FALLBACK_TYPE: ${AURA_ENGINE_FALLBACK_TYPE}
      AURA_ENGINE_FALLBACK_FOLDER_RELOAD: ${AURA_ENGINE_FALLBACK_FOLDER_RELOAD}
      AURA_ENGINE_FALLBACK_MAX_BLANK: ${AURA_ENGINE_FALLBACK_MAX_BLANK}
      AURA_ENGINE_FALLBACK_MIN_NOISE: ${AURA_ENGINE_FALLBACK_MIN_NOISE}
      AURA_ENGINE_FALLBACK_THRESHOLD: ${AURA_ENGINE_FALLBACK_THRESHOLD}
      # Misc Settings
      AURA_ENGINE_FRAME_SAMPLERATE: ${AURA_ENGINE_FRAME_SAMPLERATE}
      AURA_ENGINE_FRAME_DURATION: ${AURA_ENGINE_FRAME_DURATION}
      AURA_ENGINE_FRAME_SIZE: ${AURA_ENGINE_FRAME_SIZE}
      AURA_ENGINE_API_URL_PLAYLOG: ${AURA_ENGINE_API_URL_PLAYLOG}
      # Server Settings
      AURA_ENGINE_SERVER_TIMEOUT: ${AURA_ENGINE_SERVER_TIMEOUT}
      AURA_ENGINE_TELNET_ENABLE: ${AURA_ENGINE_TELNET_ENABLE}
      AURA_ENGINE_TELNET_HOST: ${AURA_ENGINE_TELNET_HOST}
      AURA_ENGINE_TELNET_PORT: ${AURA_ENGINE_TELNET_PORT}
      # Stream Input Settings
      AURA_ENGINE_STREAM_INPUT_MAX_BUFFER: ${AURA_ENGINE_STREAM_INPUT_MAX_BUFFER}
      AURA_ENGINE_STREAM_INPUT_TIMEOUT: ${AURA_ENGINE_STREAM_INPUT_TIMEOUT}
      # Stream Output Settings
      AURA_ENGINE_STREAM_OUTPUT_ENABLE: ${AURA_ENGINE_STREAM_OUTPUT_ENABLE}
      AURA_ENGINE_STREAM_OUTPUT_ENCODING: ${AURA_ENGINE_STREAM_OUTPUT_ENCODING}
      AURA_ENGINE_STREAM_OUTPUT_BITRATE: ${AURA_ENGINE_STREAM_OUTPUT_BITRATE}
      AURA_ENGINE_STREAM_OUTPUT_CHANNELS: ${AURA_ENGINE_STREAM_OUTPUT_CHANNELS}
      AURA_ENGINE_STREAM_OUTPUT_HOST: ${AURA_ENGINE_STREAM_OUTPUT_HOST}
      AURA_ENGINE_STREAM_OUTPUT_PORT: ${AURA_ENGINE_STREAM_OUTPUT_PORT}
      AURA_ENGINE_STREAM_OUTPUT_USER: ${AURA_ENGINE_STREAM_OUTPUT_USER}
      AURA_ENGINE_STREAM_OUTPUT_PASSWORD: ${AURA_ENGINE_STREAM_OUTPUT_PASSWORD}
      AURA_ENGINE_STREAM_OUTPUT_MOUNTPOINT: ${AURA_ENGINE_STREAM_OUTPUT_MOUNTPOINT}
      AURA_ENGINE_STREAM_OUTPUT_NAME: ${AURA_ENGINE_STREAM_OUTPUT_NAME}
      AURA_ENGINE_STREAM_OUTPUT_URL: ${AURA_ENGINE_STREAM_OUTPUT_URL}
      AURA_ENGINE_STREAM_OUTPUT_DESCRIPTION: ${AURA_ENGINE_STREAM_OUTPUT_DESCRIPTION}
      AURA_ENGINE_STREAM_OUTPUT_GENRE: ${AURA_ENGINE_STREAM_OUTPUT_GENRE}
    volumes:
      - /run/user/2872/pipewire-0:/tmp/pipewire-0
      - ./../services/:/etc/aura/:ro
      # - ./asound.conf:/etc/asound.conf
      - ${AURA_AUDIO_STORE_SOURCE}:/var/audio/source
      - ${AURA_AUDIO_STORE_PLAYLIST}:/var/audio/playlist
      - ${AURA_AUDIO_STORE_FALLBACK}:/var/audio/fallback
      - ${AURA_LOGS}:/srv/logs
      - aura_engine_socket:/srv/socket
    tmpfs:
      - /tmp
    ports:
      - 1234:1234

volumes:
  aura_engine_socket: