feat: Docker packaging — single container with Mosquitto + Node

- Dockerfile: Alpine + Node 22 + Mosquitto + supervisord
- Auto-copies config.example.json if no config.json mounted
- Named volume for data persistence (SQLite + Mosquitto)
- Ports: 3000 (web), 1883 (MQTT)
- .dockerignore excludes data, config, git, benchmarks
- README updated with Docker quickstart
This commit is contained in:
you
2026-03-20 06:06:15 +00:00
parent f0c29b38f1
commit 2e486e2a66
6 changed files with 129 additions and 1 deletions
+14
View File
@@ -0,0 +1,14 @@
# Docker
.git
node_modules
data
config.json
*.db
*.db-shm
*.db-wal
*.bak
benchmark*.sh
benchmark*.js
PERFORMANCE.md
docs/
.gitignore
+32
View File
@@ -0,0 +1,32 @@
FROM node:22-alpine
RUN apk add --no-cache mosquitto mosquitto-clients supervisor
WORKDIR /app
# Install Node dependencies
COPY package.json package-lock.json ./
RUN npm ci --production
# Copy application
COPY server.js db.js packet-store.js config.example.json ./
COPY public/ ./public/
# Supervisor config
COPY docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY docker/mosquitto.conf /etc/mosquitto/mosquitto.conf
# Create data directory for SQLite + Mosquitto persistence
RUN mkdir -p /app/data /var/lib/mosquitto && \
chown -R node:node /app/data && \
chown -R mosquitto:mosquitto /var/lib/mosquitto
# Default config: copy example if no config mounted
COPY docker/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
EXPOSE 3000 1883
VOLUME ["/app/data"]
ENTRYPOINT ["/entrypoint.sh"]
+38 -1
View File
@@ -69,7 +69,44 @@ See [PERFORMANCE.md](PERFORMANCE.md) for the full benchmark.
## Quick Start
### Prerequisites
### Docker (Recommended)
The easiest way to run MeshCore Analyzer. Includes Mosquitto MQTT broker — everything in one container.
```bash
docker build -t meshcore-analyzer .
docker run -d \
--name meshcore-analyzer \
-p 3000:3000 \
-p 1883:1883 \
-v meshcore-data:/app/data \
meshcore-analyzer
```
Open `http://localhost:3000`. Point your MeshCore gateway's MQTT to `<host-ip>:1883`.
**Custom config:**
```bash
# Copy and edit the example config
cp config.example.json config.json
# Edit config.json with your channel keys, regions, etc.
docker run -d \
--name meshcore-analyzer \
-p 3000:3000 \
-p 1883:1883 \
-v meshcore-data:/app/data \
-v $(pwd)/config.json:/app/config.json \
meshcore-analyzer
```
**Persist your database** across container rebuilds by using a named volume (`meshcore-data`) or bind mount (`-v ./data:/app/data`).
### Manual Install
### Manual Install
#### Prerequisites
- **Node.js** 18+ (tested with 22.x)
- **MQTT broker** (Mosquitto recommended) — optional, can inject packets via API
+9
View File
@@ -0,0 +1,9 @@
#!/bin/sh
# Copy example config if no config.json exists
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
exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf
+10
View File
@@ -0,0 +1,10 @@
# Mosquitto config for MeshCore Analyzer
listener 1883 0.0.0.0
allow_anonymous true
persistence true
persistence_location /var/lib/mosquitto/
# Logging
log_dest stdout
log_type warning
log_type error
+26
View File
@@ -0,0 +1,26 @@
[supervisord]
nodaemon=true
user=root
logfile=/dev/stdout
logfile_maxbytes=0
pidfile=/var/run/supervisord.pid
[program:mosquitto]
command=/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
[program:meshcore-analyzer]
command=node /app/server.js
directory=/app
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
environment=NODE_ENV="production"