appujet / lavamusic

lavalink music bot base in lavalink-client and discord.js v14
https://appujet.github.io/lavamusic/
GNU General Public License v3.0
574 stars 490 forks source link

docker-compose does not work #463

Closed colin3131 closed 1 year ago

colin3131 commented 1 year ago

With all required environment variables set (TOKEN, PREFIX, OWNER_IDS, CLIENT_ID, GUILD_ID, PRODUCTION), docker-composed did not work out of the box, none of the nodes could communicate with one another using the defined URLs. I had to change the following variables (to use pod addresses rather than localhost):

DATABASE_URL: "mongodb://mongoadmin:mongopassword@lavamusic-mongodb:27017/db?authSource=admin"
LAVALINK_URL: "lavamusic-lavalink:2333" # Your lavalink url

I'm still running into an issue where no nodes are created, no errors appearing in the logs aside from when I run the play command

Error: No nodes available, please add a node first
    at ShoukakuClient.getNode (file:///opt/lavamusic/node_modules/shoukaku/dist/index.mjs:1271:13)
    at Play.run (file:///opt/lavamusic/dist/commands/music/Play.js:46:106)
    at MessageCreate.run (file:///opt/lavamusic/dist/events/client/MessageCreate.js:187:34)

Database connects successfully, and lavamusic can resolve and send http over the lavalink URL I've added, so that's not the issue.

[5/21/2023] [4:01:01 PM] [index.js] [Lavamusic] › ▶  start     [CLIENT] 1 shard(s) spawned.
[5/21/2023] [4:01:03 PM] [Lavamusic.js] [Lavamusic] › ℹ  info      Successfully loaded commands!
[5/21/2023] [4:01:03 PM] [Lavamusic.js] [Lavamusic] › ℹ  info      Successfully loaded events!
[5/21/2023] [4:01:03 PM] [index.js] [Lavamusic] › ℹ  info      Loaded plugin: Advice Plugin v1.0.0
[5/21/2023] [4:01:03 PM] [index.js] [Lavamusic] › ℹ  info      Loaded plugin: AntiCrash Plugin v1.0.0
[5/21/2023] [4:01:03 PM] [Lavamusic.js] [Lavamusic] › ✔  success   Connected to the database!
[5/21/2023] [4:01:04 PM] [index.js] [Lavamusic] › ▶  start     [CLIENT] Shard 0 connected to Discord's Gateway.
[5/21/2023] [4:01:04 PM] [Ready.js] [Lavamusic] › ✔  success   DJRoomba#5465 is ready!
[5/21/2023] [4:01:04 PM] [Lavamusic.js] [Lavamusic] › ℹ  info      Successfully loaded slash commands!
[5/21/2023] [4:01:54 PM] [MessageCreate.js] [Lavamusic] › ✖  error     Error: No nodes available, please add a node first
root@44107560b81d:/opt/lavamusic# wget lavamusic-lavalink:2333
--2023-05-21 16:11:56--  http://lavamusic-lavalink:2333/
Resolving lavamusic-lavalink (lavamusic-lavalink)... 172.29.0.3
Connecting to lavamusic-lavalink (lavamusic-lavalink)|172.29.0.3|:2333... connected.
HTTP request sent, awaiting response... 401 Unauthorized

For reference, this is the current version of the docker compose file I'm using:

version: "3.8"
services:
  mongodb:
    container_name: lavamusic-mongodb
    image: mongo:latest
    environment:
      MONGO_INITDB_ROOT_USERNAME: mongoadmin
      MONGO_INITDB_ROOT_PASSWORD: mongopassword
    restart: on-failure
    volumes:
      - mongodb_data:/data/db

  lavalink:
    container_name: lavamusic-lavalink
    image: fredboat/lavalink:dev
    environment:
      SERVER_PORT: 2333
      SERVER_ADDRESS: 0.0.0.0
      LAVALINK_SERVER_PASSWORD: "youshallnotpass"
      LAVALINK_SERVER_SOURCES_YOUTUBE: 'true'
      LAVALINK_SERVER_SOURCES_BANDCAMP: 'true'
      LAVALINK_SERVER_SOURCES_SOUNDCLOUD: 'true'
      LAVALINK_SERVER_SOURCES_TWITCH: 'true'
      LAVALINK_SERVER_SOURCES_VIMEO: 'true'
      LAVALINK_SERVER_SOURCES_HTTP: 'true'
      LAVALINK_SERVER_SOURCES_LOCAL: 'false'
      LAVALINK_SERVER_BUFFER_DURATION_MS: 400
      LAVALINK_SERVER_FRAME_BUFFER_DURATIONS_MS: 5000
      LAVALINK_SERVER_TRACK_STRUCK_THRESHOLD_MS: 10000
      LAVALINK_SERVER_YOUTUBE_PLAYLIST_LOAD_LIMIT: 6
      LAVALINK_SERVER_PLAYER_UPDATE_INTERVAL: 5
      LAVALINK_SERVER_YOUTUBE_SEARCH_ENABLED: 'true'
      LAVALINK_SERVER_SOUNDCLOUD_SEARCH_ENABLED: 'true'
      #LAVALINK_SERVER_YOUTUBE_CONFIG_EMAIL:
      #LAVALINK_SERVER_YOUTUBE_CONFIG_PASSWORD:
      LAVALINK_SERVER_SENTRY_DSN: ""
    restart: on-failure

  lavamusic:
    container_name: lavamusic
    image: ghcr.io/brblacky/lavamusic:main
    environment:
     TOKEN: "****************" # Your bot token
     PREFIX: "-" # Your bot prefix
     OWNER_IDS: "***************" # Your id
     CLIENT_ID: "********************" # Your bot id
     GUILD_ID: "******************************" # Your server Id if you want to use the for single server
     PRODUCTION: "true" # true for production
     SEARCH_ENGINE: "ytsearch" # ytsearch, scsearch or ytmsearch
     MAX_PLAYLIST_SIZE: "100" # Max playlist size
     MAX_QUEUE_SIZE: "100" # Max queue size
     DATABASE_URL: "mongodb://mongoadmin:mongopassword@lavamusic-mongodb:27017/db?authSource=admin" # Your mongodb url
     LAVALINK_URL: "lavamusic-lavalink:2333" # Your lavalink url
     LAVALINK_AUTH: "youshallnotpass" # Your lavalink password
     LAVALINK_NAME: "Blacky" # Your lavalink name
     LAVALINK_SECURE: "false" # true if you are using https
    restart: on-failure
    depends_on:
      - lavalink
      - mongodb
    links:
      - mongodb:db
      - lavalink

volumes:
  mongodb_data:

networks:
  default:
    name: net-lavamusic
colin3131 commented 1 year ago

Figured it out, lavalink starts up a lot slower than lavamusic. Restarting lavamusic container did the trick. @brblacky I'm not too experienced with docker but if there's a way to add a container startup delay in the docker-compose file, that could solve this issue.