Fix Docker volume mounts and database path for proper persistence
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
carplay-audio:
|
||||
build: .
|
||||
@@ -10,13 +8,12 @@ services:
|
||||
volumes:
|
||||
# Mount your music library (change the left path to your music folder)
|
||||
- /Volumes/Data/Music:/data/music:ro
|
||||
# Persistent data (database, artwork, config)
|
||||
- ./data/artwork:/app/artwork
|
||||
- ./data/database/audio_server.db:/app/audio_server.db
|
||||
- ./data/database/config.json:/app/config.json
|
||||
# Persistent data (database and artwork stored in data directory)
|
||||
- ./data:/app/data
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- PORT=4000
|
||||
- DB_PATH=/app/data/audio_server.db
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:4000/health"]
|
||||
interval: 30s
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import sqlite3 from 'sqlite3';
|
||||
import { promisify } from 'util';
|
||||
|
||||
const db = new sqlite3.Database('./audio_server.db');
|
||||
const dbPath = process.env.DB_PATH || './audio_server.db';
|
||||
const db = new sqlite3.Database(dbPath);
|
||||
|
||||
const run = promisify(db.run.bind(db));
|
||||
const get = promisify(db.get.bind(db));
|
||||
|
||||
@@ -51,7 +51,12 @@ const libraryPath = path.isAbsolute(config.libraryPath)
|
||||
? config.libraryPath
|
||||
: path.join(process.cwd(), config.libraryPath);
|
||||
app.use('/audio', express.static(libraryPath));
|
||||
app.use('/artwork', express.static(path.join(process.cwd(), 'artwork')));
|
||||
|
||||
// Artwork can be in data directory (Docker) or root (local)
|
||||
const artworkPath = process.env.NODE_ENV === 'production'
|
||||
? path.join(process.cwd(), 'data', 'artwork')
|
||||
: path.join(process.cwd(), 'artwork');
|
||||
app.use('/artwork', express.static(artworkPath));
|
||||
|
||||
// Health check
|
||||
app.get('/health', (req, res) => {
|
||||
|
||||
Reference in New Issue
Block a user