diff --git a/docker/.dockerignore b/.dockerignore similarity index 100% rename from docker/.dockerignore rename to .dockerignore diff --git a/.env.example b/.env.example index ecc0b27..5e6c14a 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,4 @@ -# MeshCore Hub - Environment Configuration Example +# MeshCore Hub - Docker Compose Environment Configuration # Copy this file to .env and customize values # =================== @@ -8,46 +8,41 @@ # Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL) LOG_LEVEL=INFO -# MQTT Broker Settings -MQTT_HOST=localhost -MQTT_PORT=1883 +# MQTT Broker Settings (internal use) MQTT_USERNAME= MQTT_PASSWORD= MQTT_PREFIX=meshcore +# External MQTT port mapping +MQTT_EXTERNAL_PORT=1883 +MQTT_WS_PORT=9001 + # =================== # Interface Settings # =================== -# Mode of operation (RECEIVER or SENDER) -INTERFACE_MODE=RECEIVER - -# Serial port for MeshCore device +# Serial port for receiver device SERIAL_PORT=/dev/ttyUSB0 + +# Serial port for sender device (if separate) +SERIAL_PORT_SENDER=/dev/ttyUSB1 + +# Baud rate for serial communication SERIAL_BAUD=115200 -# Use mock device for testing (true/false) -MOCK_DEVICE=false - -# =================== -# Collector Settings -# =================== - -# Database connection URL -# SQLite: sqlite:///./meshcore.db -# PostgreSQL: postgresql://user:password@localhost/meshcore -DATABASE_URL=sqlite:///./meshcore.db +# Optional node address override (64-char hex string) +NODE_ADDRESS= +NODE_ADDRESS_SENDER= # =================== # API Settings # =================== -# API Server binding -API_HOST=0.0.0.0 +# External API port API_PORT=8000 -# API Keys for authentication -# Generate secure keys for production! +# API Keys for authentication (generate secure keys for production!) +# Example: openssl rand -hex 32 API_READ_KEY= API_ADMIN_KEY= @@ -55,16 +50,10 @@ API_ADMIN_KEY= # Web Dashboard Settings # =================== -# Web Server binding -WEB_HOST=0.0.0.0 +# External web port WEB_PORT=8080 -# API connection for web dashboard -API_BASE_URL=http://localhost:8000 -API_KEY= - # Network Information (displayed on web dashboard) -NETWORK_DOMAIN= NETWORK_NAME=MeshCore Network NETWORK_CITY= NETWORK_COUNTRY= @@ -73,5 +62,5 @@ NETWORK_RADIO_CONFIG= NETWORK_CONTACT_EMAIL= NETWORK_CONTACT_DISCORD= -# Path to members JSON file -MEMBERS_FILE=members.json +# Path to members JSON file (mounted into container) +MEMBERS_FILE_PATH=./data/members.json diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index bd35981..9af6c0a 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -50,7 +50,7 @@ jobs: uses: docker/build-push-action@v5 with: context: . - file: docker/Dockerfile + file: Dockerfile push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} @@ -60,6 +60,6 @@ jobs: - name: Test Docker image if: github.event_name == 'pull_request' run: | - docker build -t meshcore-hub-test -f docker/Dockerfile . + docker build -t meshcore-hub-test -f Dockerfile . docker run --rm meshcore-hub-test --version docker run --rm meshcore-hub-test --help diff --git a/.gitignore b/.gitignore index 0e2a9aa..d235f99 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,8 @@ share/python-wheels/ *.egg MANIFEST uv.lock +/docker-compose.yml + # PyInstaller # Usually these files are written by a python script from a template diff --git a/AGENTS.md b/AGENTS.md index f640ce2..24e05b7 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -274,9 +274,12 @@ meshcore-hub/ ├── alembic/ │ ├── env.py │ └── versions/ -└── docker/ - ├── Dockerfile - └── docker-compose.yml +├── etc/ +│ └── mosquitto.conf # MQTT broker configuration +├── data/ +│ └── members.json # Network members data +├── Dockerfile # Docker build configuration +└── docker-compose.yml # Docker Compose services ``` ## MQTT Topic Structure diff --git a/docker/Dockerfile b/Dockerfile similarity index 100% rename from docker/Dockerfile rename to Dockerfile diff --git a/README.md b/README.md index 8f567b2..67fb5aa 100644 --- a/README.md +++ b/README.md @@ -333,7 +333,10 @@ meshcore-hub/ │ └── web/ # Web dashboard ├── tests/ # Test suite ├── alembic/ # Database migrations -├── docker/ # Docker configuration +├── etc/ # Configuration files (mosquitto.conf) +├── data/ # Data files (members.json) +├── Dockerfile # Docker build configuration +├── docker-compose.yml # Docker Compose services ├── PROMPT.md # Project specification ├── SCHEMAS.md # Event schema documentation ├── PLAN.md # Implementation plan diff --git a/docker/members.json b/data/members.json similarity index 100% rename from docker/members.json rename to data/members.json diff --git a/docker/docker-compose.yml b/docker-compose.yml.example similarity index 94% rename from docker/docker-compose.yml rename to docker-compose.yml.example index 133b0ba..ccb6c11 100644 --- a/docker/docker-compose.yml +++ b/docker-compose.yml.example @@ -31,7 +31,7 @@ services: - "${MQTT_EXTERNAL_PORT:-1883}:1883" - "${MQTT_WS_PORT:-9001}:9001" volumes: - - ./mosquitto.conf:/mosquitto/config/mosquitto.conf:ro + - ./etc/mosquitto.conf:/mosquitto/config/mosquitto.conf:ro - mosquitto_data:/mosquitto/data - mosquitto_log:/mosquitto/log healthcheck: @@ -46,8 +46,8 @@ services: # ========================================================================== interface-receiver: build: - context: .. - dockerfile: docker/Dockerfile + context: . + dockerfile: Dockerfile container_name: meshcore-interface-receiver profiles: - interface-receiver @@ -82,8 +82,8 @@ services: # ========================================================================== interface-sender: build: - context: .. - dockerfile: docker/Dockerfile + context: . + dockerfile: Dockerfile container_name: meshcore-interface-sender profiles: - interface-sender @@ -118,8 +118,8 @@ services: # ========================================================================== interface-mock-receiver: build: - context: .. - dockerfile: docker/Dockerfile + context: . + dockerfile: Dockerfile container_name: meshcore-interface-mock-receiver profiles: - mock @@ -149,8 +149,8 @@ services: # ========================================================================== collector: build: - context: .. - dockerfile: docker/Dockerfile + context: . + dockerfile: Dockerfile container_name: meshcore-collector profiles: - collector @@ -183,8 +183,8 @@ services: # ========================================================================== api: build: - context: .. - dockerfile: docker/Dockerfile + context: . + dockerfile: Dockerfile container_name: meshcore-api profiles: - api @@ -225,8 +225,8 @@ services: # ========================================================================== web: build: - context: .. - dockerfile: docker/Dockerfile + context: . + dockerfile: Dockerfile container_name: meshcore-web profiles: - web @@ -253,7 +253,7 @@ services: - NETWORK_CONTACT_DISCORD=${NETWORK_CONTACT_DISCORD:-} - MEMBERS_FILE=${MEMBERS_FILE:-} volumes: - - ${MEMBERS_FILE_PATH:-./members.json}:/app/members.json:ro + - ${MEMBERS_FILE_PATH:-./data/members.json}:/app/members.json:ro command: ["web"] healthcheck: test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8080/health')"] @@ -267,8 +267,8 @@ services: # ========================================================================== db-migrate: build: - context: .. - dockerfile: docker/Dockerfile + context: . + dockerfile: Dockerfile container_name: meshcore-db-migrate profiles: - migrate diff --git a/docker/.env.example b/docker/.env.example deleted file mode 100644 index 8f8de42..0000000 --- a/docker/.env.example +++ /dev/null @@ -1,66 +0,0 @@ -# MeshCore Hub - Docker Compose Environment Configuration -# Copy this file to .env and customize values - -# =================== -# Common Settings -# =================== - -# Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL) -LOG_LEVEL=INFO - -# MQTT Broker Settings (internal use) -MQTT_USERNAME= -MQTT_PASSWORD= -MQTT_PREFIX=meshcore - -# External MQTT port mapping -MQTT_EXTERNAL_PORT=1883 -MQTT_WS_PORT=9001 - -# =================== -# Interface Settings -# =================== - -# Serial port for receiver device -SERIAL_PORT=/dev/ttyUSB0 - -# Serial port for sender device (if separate) -SERIAL_PORT_SENDER=/dev/ttyUSB1 - -# Baud rate for serial communication -SERIAL_BAUD=115200 - -# Optional node address override (64-char hex string) -NODE_ADDRESS= -NODE_ADDRESS_SENDER= - -# =================== -# API Settings -# =================== - -# External API port -API_PORT=8000 - -# API Keys for authentication (generate secure keys for production!) -# Example: openssl rand -hex 32 -API_READ_KEY= -API_ADMIN_KEY= - -# =================== -# Web Dashboard Settings -# =================== - -# External web port -WEB_PORT=8080 - -# Network Information (displayed on web dashboard) -NETWORK_NAME=MeshCore Network -NETWORK_CITY= -NETWORK_COUNTRY= -NETWORK_LOCATION= -NETWORK_RADIO_CONFIG= -NETWORK_CONTACT_EMAIL= -NETWORK_CONTACT_DISCORD= - -# Path to members JSON file (mounted into container) -MEMBERS_FILE_PATH=./members.json diff --git a/docker/mosquitto.conf b/etc/mosquitto.conf similarity index 100% rename from docker/mosquitto.conf rename to etc/mosquitto.conf diff --git a/tests/e2e/docker-compose.test.yml b/tests/e2e/docker-compose.test.yml index de6dedc..e95e8f2 100644 --- a/tests/e2e/docker-compose.test.yml +++ b/tests/e2e/docker-compose.test.yml @@ -15,7 +15,7 @@ services: ports: - "11883:1883" volumes: - - ../../docker/mosquitto.conf:/mosquitto/config/mosquitto.conf:ro + - ../../etc/mosquitto.conf:/mosquitto/config/mosquitto.conf:ro healthcheck: test: ["CMD", "mosquitto_sub", "-t", "$$SYS/#", "-C", "1", "-i", "healthcheck", "-W", "3"] interval: 5s @@ -27,7 +27,7 @@ services: interface-mock: build: context: ../.. - dockerfile: docker/Dockerfile + dockerfile: Dockerfile container_name: meshcore-test-interface depends_on: mqtt: @@ -51,7 +51,7 @@ services: collector: build: context: ../.. - dockerfile: docker/Dockerfile + dockerfile: Dockerfile container_name: meshcore-test-collector depends_on: mqtt: @@ -76,7 +76,7 @@ services: api: build: context: ../.. - dockerfile: docker/Dockerfile + dockerfile: Dockerfile container_name: meshcore-test-api depends_on: mqtt: @@ -109,7 +109,7 @@ services: web: build: context: ../.. - dockerfile: docker/Dockerfile + dockerfile: Dockerfile container_name: meshcore-test-web depends_on: api: