Fix Docker volume mounts and database path for proper persistence
This commit is contained in:
@@ -1,5 +1,3 @@
|
|||||||
version: '3.8'
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
carplay-audio:
|
carplay-audio:
|
||||||
build: .
|
build: .
|
||||||
@@ -10,13 +8,12 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
# Mount your music library (change the left path to your music folder)
|
# Mount your music library (change the left path to your music folder)
|
||||||
- /Volumes/Data/Music:/data/music:ro
|
- /Volumes/Data/Music:/data/music:ro
|
||||||
# Persistent data (database, artwork, config)
|
# Persistent data (database and artwork stored in data directory)
|
||||||
- ./data/artwork:/app/artwork
|
- ./data:/app/data
|
||||||
- ./data/database/audio_server.db:/app/audio_server.db
|
|
||||||
- ./data/database/config.json:/app/config.json
|
|
||||||
environment:
|
environment:
|
||||||
- NODE_ENV=production
|
- NODE_ENV=production
|
||||||
- PORT=4000
|
- PORT=4000
|
||||||
|
- DB_PATH=/app/data/audio_server.db
|
||||||
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
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import sqlite3 from 'sqlite3';
|
import sqlite3 from 'sqlite3';
|
||||||
import { promisify } from 'util';
|
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 run = promisify(db.run.bind(db));
|
||||||
const get = promisify(db.get.bind(db));
|
const get = promisify(db.get.bind(db));
|
||||||
|
|||||||
@@ -51,7 +51,12 @@ const libraryPath = path.isAbsolute(config.libraryPath)
|
|||||||
? config.libraryPath
|
? config.libraryPath
|
||||||
: path.join(process.cwd(), config.libraryPath);
|
: path.join(process.cwd(), config.libraryPath);
|
||||||
app.use('/audio', express.static(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
|
// Health check
|
||||||
app.get('/health', (req, res) => {
|
app.get('/health', (req, res) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user