From 8e44de6bb5e58c582507e40cf86e0995496d99c3 Mon Sep 17 00:00:00 2001 From: Paul Bailey Date: Mon, 8 Dec 2025 00:21:37 +0000 Subject: [PATCH] Add LIBRARY_PATH environment variable for Docker to override config.json path --- docker-compose.yml | 1 + src/scripts/scanLibrary.js | 3 ++- src/server.js | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index c7989a5..e92b3fc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,6 +14,7 @@ services: - NODE_ENV=production - PORT=4000 - DB_PATH=/app/data/audio_server.db + - LIBRARY_PATH=/data/music healthcheck: test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:4000/health"] interval: 30s diff --git a/src/scripts/scanLibrary.js b/src/scripts/scanLibrary.js index 7dd5d19..76be25d 100644 --- a/src/scripts/scanLibrary.js +++ b/src/scripts/scanLibrary.js @@ -10,7 +10,8 @@ await initDatabase(); // Load config to get library path const config = await loadConfig(); -const libraryPath = process.argv[2] || config.libraryPath; +// Override with environment variable if set +const libraryPath = process.argv[2] || process.env.LIBRARY_PATH || config.libraryPath; // Resolve path const resolvedPath = path.isAbsolute(libraryPath) diff --git a/src/server.js b/src/server.js index be5c518..87d25b9 100644 --- a/src/server.js +++ b/src/server.js @@ -18,6 +18,10 @@ const app = express(); // Load config const config = await loadConfig(); +// Override with environment variables if set +if (process.env.LIBRARY_PATH) { + config.libraryPath = process.env.LIBRARY_PATH; +} const PORT = process.env.PORT || config.port || 3000; // Middleware