mirror of
https://github.com/MarekWo/mc-webui.git
synced 2026-03-28 17:42:45 +01:00
feat(v2): Single container Docker setup with direct USB access
Replace two-container bridge architecture with single container. Dockerfile adds udev for serial device support. docker-compose.yml: one service with cgroup rules for ttyUSB/ttyACM, SQLite DB path, backup settings, optional TCP mode. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
12
Dockerfile
12
Dockerfile
@@ -1,10 +1,13 @@
|
|||||||
# mc-webui Dockerfile
|
# mc-webui v2 Dockerfile
|
||||||
# Python 3.11+ with Flask (meshcore-cli runs in separate bridge container)
|
# Single container with direct MeshCore device access (serial/TCP)
|
||||||
|
|
||||||
FROM python:3.11-slim
|
FROM python:3.11-slim
|
||||||
|
|
||||||
# Install curl for testing
|
# Install system deps: curl (healthcheck), udev (serial device support)
|
||||||
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
|
RUN apt-get update && apt-get install -y \
|
||||||
|
curl \
|
||||||
|
udev \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Set working directory
|
# Set working directory
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
@@ -17,7 +20,6 @@ RUN pip install --no-cache-dir -r requirements.txt
|
|||||||
|
|
||||||
# Copy application code
|
# Copy application code
|
||||||
# Note: Run 'python -m app.version freeze' before build to include version info
|
# Note: Run 'python -m app.version freeze' before build to include version info
|
||||||
# The version_frozen.py file will be copied automatically if it exists
|
|
||||||
COPY app/ ./app/
|
COPY app/ ./app/
|
||||||
|
|
||||||
# Expose Flask port
|
# Expose Flask port
|
||||||
|
|||||||
@@ -1,71 +1,40 @@
|
|||||||
|
# mc-webui v2 — single container with direct device access
|
||||||
services:
|
services:
|
||||||
# MeshCore Bridge - Handles USB communication with meshcli
|
|
||||||
meshcore-bridge:
|
|
||||||
build:
|
|
||||||
context: ./meshcore-bridge
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
container_name: meshcore-bridge
|
|
||||||
restart: unless-stopped
|
|
||||||
# Grant access to serial devices for auto-detection
|
|
||||||
# This allows MC_SERIAL_PORT=auto to work without specifying device upfront
|
|
||||||
# Major 188 = ttyUSB (CP2102, CH340, etc.), Major 166 = ttyACM (ESP32-S3, etc.)
|
|
||||||
device_cgroup_rules:
|
|
||||||
- 'c 188:* rmw'
|
|
||||||
- 'c 166:* rmw'
|
|
||||||
volumes:
|
|
||||||
- "${MC_CONFIG_DIR}:/root/.config/meshcore:rw"
|
|
||||||
- "/dev:/dev"
|
|
||||||
environment:
|
|
||||||
- MC_SERIAL_PORT=${MC_SERIAL_PORT:-auto}
|
|
||||||
- MC_CONFIG_DIR=/root/.config/meshcore
|
|
||||||
- MC_DEVICE_NAME=${MC_DEVICE_NAME:-auto}
|
|
||||||
- TZ=${TZ:-UTC}
|
|
||||||
networks:
|
|
||||||
- meshcore-net
|
|
||||||
healthcheck:
|
|
||||||
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:5001/health')"]
|
|
||||||
interval: 30s
|
|
||||||
timeout: 10s
|
|
||||||
retries: 3
|
|
||||||
start_period: 10s
|
|
||||||
|
|
||||||
# Main Web UI - Communicates with bridge via HTTP
|
|
||||||
mc-webui:
|
mc-webui:
|
||||||
build:
|
build: .
|
||||||
context: .
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
container_name: mc-webui
|
container_name: mc-webui
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- "${FLASK_PORT:-5000}:${FLASK_PORT:-5000}"
|
- "${FLASK_PORT:-5000}:${FLASK_PORT:-5000}"
|
||||||
|
# Grant access to serial devices for auto-detection
|
||||||
|
# Major 188 = ttyUSB (CP2102, CH340), Major 166 = ttyACM (ESP32-S3)
|
||||||
|
device_cgroup_rules:
|
||||||
|
- 'c 188:* rmw'
|
||||||
|
- 'c 166:* rmw'
|
||||||
volumes:
|
volumes:
|
||||||
- "${MC_CONFIG_DIR}:/root/.config/meshcore:rw"
|
- "${MC_CONFIG_DIR:-./data}:/data:rw"
|
||||||
- "${MC_ARCHIVE_DIR:-./archive}:/root/.archive/meshcore:rw"
|
- "/dev:/dev"
|
||||||
environment:
|
environment:
|
||||||
- MC_BRIDGE_URL=http://meshcore-bridge:5001/cli
|
- MC_SERIAL_PORT=${MC_SERIAL_PORT:-auto}
|
||||||
- MC_DEVICE_NAME=${MC_DEVICE_NAME}
|
- MC_DEVICE_NAME=${MC_DEVICE_NAME:-MeshCore}
|
||||||
- MC_CONFIG_DIR=/root/.config/meshcore
|
- MC_CONFIG_DIR=/data
|
||||||
- MC_ARCHIVE_DIR=/root/.archive/meshcore
|
- MC_DB_PATH=/data/mc-webui.db
|
||||||
- MC_ARCHIVE_ENABLED=${MC_ARCHIVE_ENABLED:-true}
|
# TCP mode (uncomment to use meshcore-proxy instead of serial):
|
||||||
- MC_ARCHIVE_RETENTION_DAYS=${MC_ARCHIVE_RETENTION_DAYS:-7}
|
# - MC_TCP_HOST=192.168.1.100
|
||||||
|
# - MC_TCP_PORT=5000
|
||||||
|
- MC_BACKUP_ENABLED=${MC_BACKUP_ENABLED:-true}
|
||||||
|
- MC_BACKUP_HOUR=${MC_BACKUP_HOUR:-2}
|
||||||
|
- MC_BACKUP_RETENTION_DAYS=${MC_BACKUP_RETENTION_DAYS:-7}
|
||||||
- FLASK_HOST=${FLASK_HOST:-0.0.0.0}
|
- FLASK_HOST=${FLASK_HOST:-0.0.0.0}
|
||||||
- FLASK_PORT=${FLASK_PORT:-5000}
|
- FLASK_PORT=${FLASK_PORT:-5000}
|
||||||
- FLASK_DEBUG=${FLASK_DEBUG:-false}
|
- FLASK_DEBUG=${FLASK_DEBUG:-false}
|
||||||
- TZ=${TZ:-UTC}
|
- TZ=${TZ:-UTC}
|
||||||
env_file:
|
env_file:
|
||||||
- .env
|
- path: .env
|
||||||
depends_on:
|
required: false
|
||||||
meshcore-bridge:
|
|
||||||
condition: service_healthy
|
|
||||||
networks:
|
|
||||||
- meshcore-net
|
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "python", "-c", "import urllib.request, os; urllib.request.urlopen(f'http://localhost:{os.environ.get(\"FLASK_PORT\", \"5000\")}/api/status')"]
|
test: ["CMD", "curl", "-f", "http://localhost:5000/health"]
|
||||||
interval: 30s
|
interval: 30s
|
||||||
timeout: 10s
|
timeout: 10s
|
||||||
retries: 3
|
retries: 3
|
||||||
start_period: 10s
|
start_period: 15s
|
||||||
|
|
||||||
networks:
|
|
||||||
meshcore-net:
|
|
||||||
driver: bridge
|
|
||||||
|
|||||||
Reference in New Issue
Block a user