Add LIBRARY_PATH environment variable for Docker to override config.json path

This commit is contained in:
2025-12-08 00:21:37 +00:00
parent ee433157f4
commit 8e44de6bb5
3 changed files with 7 additions and 1 deletions

View File

@@ -14,6 +14,7 @@ services:
- NODE_ENV=production - NODE_ENV=production
- PORT=4000 - PORT=4000
- DB_PATH=/app/data/audio_server.db - DB_PATH=/app/data/audio_server.db
- LIBRARY_PATH=/data/music
healthcheck: healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:4000/health"] test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:4000/health"]
interval: 30s interval: 30s

View File

@@ -10,7 +10,8 @@ await initDatabase();
// Load config to get library path // Load config to get library path
const config = await loadConfig(); 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 // Resolve path
const resolvedPath = path.isAbsolute(libraryPath) const resolvedPath = path.isAbsolute(libraryPath)

View File

@@ -18,6 +18,10 @@ const app = express();
// Load config // Load config
const config = await loadConfig(); 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; const PORT = process.env.PORT || config.port || 3000;
// Middleware // Middleware