chore: Refine Docker configuration for serial device handling

- Updated docker-compose.yml to clarify device access instructions for Linux and added notes for ARM devices regarding network mode.
- Enhanced docker-setup.sh to resolve symlinks for serial devices, improving Docker compatibility and providing fallback options for device paths.
This commit is contained in:
agessaman
2026-01-17 10:57:34 -08:00
parent 6a1a78cb2a
commit 1d60475186
2 changed files with 22 additions and 14 deletions
+6 -9
View File
@@ -12,18 +12,15 @@ services:
container_name: meshcore-bot
restart: unless-stopped
# Device access for serial ports
# NOTE: Docker Desktop on macOS does NOT support device passthrough
# Options for macOS:
# 1. Use TCP connection (if device supports it) - configure in config.ini
# 2. Use a serial-to-TCP bridge (e.g., socat) on the host
# 3. Run the bot natively on macOS instead of Docker
# For Linux: Uncomment and adjust device path below
# Device access for serial ports (Linux)
# Uncomment and adjust if using serial connection
# devices:
# - /dev/ttyUSB0:/dev/ttyUSB0
# Network mode for host access (needed for BLE and some serial setups)
# Uncomment if you need host network access
# NOTE: On some ARM devices (Orange Pi, Raspberry Pi) with Docker bridge networking issues,
# you may need to uncomment this to bypass bridge networking
# network_mode: host
# Environment variables (optional, can override config.ini settings)
@@ -44,8 +41,8 @@ services:
# Port mappings (if web viewer is enabled)
# Uncomment and adjust if using web viewer
ports:
- "8082:8080"
# ports:
# - "8080:8080"
# Logging configuration
logging:
+16 -5
View File
@@ -217,13 +217,24 @@ fi
# Update config.ini with serial device if found
if [ -n "$SERIAL_DEVICE" ]; then
if [[ "$PLATFORM" == "Linux" ]] && [[ "$SERIAL_DEVICE" == /dev/serial/by-id/* ]]; then
# On Linux with by-id path, use it directly in config (more stable)
# On Linux with by-id path, resolve to actual device for Docker compatibility
# Docker containers may not resolve symlinks correctly, so use the actual device
ACTUAL_DEVICE=$(readlink -f "$SERIAL_DEVICE" 2>/dev/null || echo "")
if [ -n "$ACTUAL_DEVICE" ] && [ -e "$ACTUAL_DEVICE" ]; then
# Use actual device path for better Docker compatibility
update_config "Connection" "serial_port" "$ACTUAL_DEVICE"
echo "✓ Updated config.ini with serial port: $ACTUAL_DEVICE"
echo " (resolved from $SERIAL_DEVICE)"
else
# Fallback to by-id path if resolution fails
update_config "Connection" "serial_port" "$SERIAL_DEVICE"
echo "✓ Updated config.ini with serial port: $SERIAL_DEVICE"
echo " ⚠️ Note: If Docker can't access this symlink, use the actual device path"
fi
elif [[ "$PLATFORM" == "Linux" ]]; then
# On Linux, use the device path directly
update_config "Connection" "serial_port" "$SERIAL_DEVICE"
echo "✓ Updated config.ini with serial port: $SERIAL_DEVICE"
elif [[ "$PLATFORM" == "Linux" ]]; then
# On Linux, use the Docker mapped path in config
update_config "Connection" "serial_port" "$DOCKER_DEVICE_PATH"
echo "✓ Updated config.ini with serial port: $DOCKER_DEVICE_PATH (mapped from $SERIAL_DEVICE)"
else
# macOS: just note it, but user needs to handle differently
update_config "Connection" "serial_port" "$SERIAL_DEVICE"