fix: config.json load order — bind-mount first, data/ fallback

Broke MQTT by reading example config from data/ instead of the real
bind-mounted /app/config.json. Now checks app dir first.
This commit is contained in:
you
2026-03-23 05:03:03 +00:00
parent 8984b921f0
commit 4a5cd9fef4
2 changed files with 8 additions and 11 deletions
+5 -8
View File
@@ -1,15 +1,12 @@
#!/bin/sh
# Copy example config if no config.json exists (check volume mount first)
if [ ! -f /app/data/config.json ]; then
echo "[entrypoint] No config.json found in /app/data/, copying example"
cp /app/config.example.json /app/data/config.json
# Copy example config if no config.json exists at app root (not bind-mounted)
if [ ! -f /app/config.json ]; then
echo "[entrypoint] No config.json found, copying from config.example.json"
cp /app/config.example.json /app/config.json
fi
# Symlink so the app finds it at /app/config.json
ln -sf /app/data/config.json /app/config.json
# Same for theme.json (optional)
# theme.json: check data/ volume (admin-editable on host)
if [ -f /app/data/theme.json ]; then
ln -sf /app/data/theme.json /app/theme.json
fi
+3 -3
View File
@@ -7,10 +7,10 @@ const { WebSocketServer } = require('ws');
const mqtt = require('mqtt');
const path = require('path');
const fs = require('fs');
// Config: checks data/ dir first (Docker volume), then app dir
// Config: bind-mounted config.json first, then fall back to data/ dir
const CONFIG_PATHS = [
path.join(__dirname, 'data', 'config.json'),
path.join(__dirname, 'config.json')
path.join(__dirname, 'config.json'),
path.join(__dirname, 'data', 'config.json')
];
function loadConfigFile() {
for (const p of CONFIG_PATHS) {