rafalopilowski1 / djSonic

WIP Discord bot written in Rust for playing music from SubSonic API (supporting FunkWhale)
2 stars 0 forks source link

Possible docker improvments #33

Closed kpostekk closed 2 years ago

kpostekk commented 2 years ago

Dockerfile related possible improvments:

Other quirks:

rafalopilowski1 commented 2 years ago
  • Could use multistage build to speedup build process and reduce image size (compile in a builder, copy binary to runner, install ffmpeg)
  • Using alpine linux based images is overall better than using debian based ones

Apperantly there are FFmpeg Alpine images for Docker (https://github.com/jrottenberg/ffmpeg)

rafalopilowski1 commented 2 years ago

TL;DR - musl has several issues with multi-threading (+ performance overhead in heap allocation) and as it is main C library on Alpine Linux, building Docker image on that distro is not possible - bot crashes when trying to lock the mutex inside songbird.

Switching base image to minimal Ubuntu (glib) + static ffmpeg libraries + multi-stage build resulted in decreasing 2.5 GB image into ~215 MB

Mostly major tasks were completed. Closing