Add LIBRARY_PATH environment variable for Docker to override config.json path
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user