How to Setup a Lavalink Server on Ubuntu 20.04 using Docker-Compose
16/01/2023
Server Requirements
I've noticed CPU usage tends to be fairly high once you have more than a few concurrent streams happening at the same time, so if you're planning on running a public node (such as the nodes found on freelavalink.lexnet.cc) then you'll either want more than 1 vCPU or a high frequency vCPU such as an 11th GEN or higher Intel Core or the equivilent Ryzen. 1GB+ of RAM is recommended aswell as 10GB of disk space.
Step 1 - Install docker & docker-compose
Firstly update your system, on Debian you can use the below command.
sudo apt-get update && sudo apt upgrade
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
sudo apt install docker-compose
Step 2 - Setup your docker-compose file
Create a directory called "lavalink" a file called "docker-compose.yml" within that directory.
mkdir lavalink
cd lavalink
nano docker-compose.yml
version: "3"
services:
lavalink:
image: fredboat/lavalink:dev
container_name: lavalink
ports:
- "8000:8000"
hostname: lavalink
restart: unless-stopped
volumes:
- /root/lavalink/application.yml:/opt/Lavalink/application.yml:ro
server: # REST and WS server
port: 8000
address: 0.0.0.0
lavalink:
server:
password: "yourpasswordhere"
sources:
youtube: true
bandcamp: true
soundcloud: true
twitch: true
vimeo: true
http: true
local: false
bufferDurationMs: 400 # The duration of the NAS buffer. Higher values fare better against longer GC pauses. Minimum o> frameBufferDurationMs: 5000 # How many milliseconds of audio to keep buffered
opusEncodingQuality: 10 # Opus encoder quality. Valid values range from 0 to 10, where 10 is best quality but is the > resamplingQuality: LOW # Quality of resampling operations. Valid values are LOW, MEDIUM and HIGH, where HIGH uses the> trackStuckThresholdMs: 10000 # The threshold f>
youtubeSearchEnabled: true
soundcloudSearchEnabled: true
gc-warnings: true
#ratelimit:
#ipBlocks: ["1.0.0.0/8", "..."] # list of ip blocks
#excludedIps: ["...", "..."] # ips which should be explicit excluded from usage by lavalink
#strategy: "RotateOnBan" # RotateOnBan | LoadBalance | NanoSwitch | RotatingNanoSwitch
#searchTriggersFail: true # Whether a search 429 should trigger marking the ip as failing
#retryLimit: -1 # -1 = use default lavaplayer value | 0 = infinity | >0 = retry will happen this numbers times
#youtubeConfig: # Required for avoiding all age restrictions by YouTube, some restricted videos still can be played w>
#email: "" # Email of Google account
#password: "" # Password of Google account
#httpConfig: # Useful for blocking bad-actors from ip-grabbing your music node and attacking it, this way only the ht>
#proxyHost: "localhost" # Hostname of the proxy, (ip or domain)
#proxyPort: 3128 # Proxy port, 3128 is the default for squidProxy
#proxyUser: "" # Optional user for basic authentication fields, leave blank if you don't use basic auth
#proxyPassword: "" # Password for basic authentication
metrics:
prometheus:
enabled: false
endpoint: /metrics
sentry:
dsn: ""
environment: ""
# tags:
# some_key: some_value
# another_key: another_value
logging:
file:
path: ./logs/
level:
root: INFO
lavalink: INFO
logback:
rollingpolicy:
max-file-size: 1GB
max-history: 30
Step 3 - Starting the server
Once the application.yml file is created you should be ready to go, run the docker-compose up command & detach the instance with the -d flag.
docker-compose up -d