Pre-compile Python bytecode in Dockerimage for faster startup
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Mon, 23 Feb 2026 00:36:13 +0000 (01:36 +0100)
committerMarcel van der Veldt <m.vanderveldt@outlook.com>
Mon, 23 Feb 2026 00:36:13 +0000 (01:36 +0100)
Dockerfile

index 913c50838589cb43cba242e6b0ca345f4ed5cb70..f215d796c9a0e3b28a4b5d482f5187a42da66619 100644 (file)
@@ -38,6 +38,9 @@ RUN uv pip install \
     --no-cache \
     "music-assistant@dist/music_assistant-${MASS_VERSION}-py3-none-any.whl"
 
+# Pre-compile Python bytecode for faster startup
+RUN $VIRTUAL_ENV/bin/python -m compileall -q $VIRTUAL_ENV/lib/python*/site-packages/music_assistant
+
 # we need to set (very permissive) permissions to the workdir
 # and /tmp to allow running the container as non-root
 # IMPORTANT: chmod here, NOT on the final image, to avoid creating extra layers and increase size!