From f0b44d28abe62f7e84907c344cd866e5bd46dbbe Mon Sep 17 00:00:00 2001 From: Louis King Date: Thu, 16 Apr 2026 23:47:34 +0100 Subject: [PATCH] =?UTF-8?q?Rename=20Docker=20volumes:=20hub=5Fdata?= =?UTF-8?q?=E2=86=92data,=20mqtt=5Fbroker=5Fdata=E2=86=92mqtt=5Fdata;=20re?= =?UTF-8?q?name=20db-migrate=20service=20to=20migrate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.example | 2 +- Makefile | 2 +- README.md | 14 +++++++------- UPGRADING.md | 16 ++++++++-------- docker-compose.dev.yml | 2 +- docker-compose.yml | 26 +++++++++++++------------- 6 files changed, 31 insertions(+), 31 deletions(-) diff --git a/.env.example b/.env.example index 3b363d9..a2116b1 100644 --- a/.env.example +++ b/.env.example @@ -31,7 +31,7 @@ # Docker Compose project name # Used as a prefix for container names (e.g., hub-api) and volume names -# (e.g., hub_hub_data). Change per instance when running multiple deployments +# (e.g., hub_data). Change per instance when running multiple deployments # on the same Docker host (e.g., hub-prod, hub-beta, hub-stg). # For multi-instance setups, see the "Multi-Instance Deployment" section in README.md. COMPOSE_PROJECT_NAME=hub diff --git a/Makefile b/Makefile index 2d94bd4..a86d0bb 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ endif COMPOSE_PROJECT_NAME ?= hub PROFILES ?= mqtt core COMPOSE_FILES = -f docker-compose.yml -f docker-compose.dev.yml -VOLUMES = $(COMPOSE_PROJECT_NAME)_hub_data $(COMPOSE_PROJECT_NAME)_mqtt_broker_data \ +VOLUMES = $(COMPOSE_PROJECT_NAME)_data $(COMPOSE_PROJECT_NAME)_mqtt_data \ $(COMPOSE_PROJECT_NAME)_observer_data .PHONY: build up down logs backup restore diff --git a/README.md b/README.md index cbd7ccc..a513b2c 100644 --- a/README.md +++ b/README.md @@ -101,18 +101,18 @@ Service profiles: | Profile | Services | Use Case | | ---------- | ------------------------------- | ----------------------------------------- | -| `all` | db-migrate, collector, api, web | Everything on one host | -| `core` | db-migrate, collector, api, web | Central server infrastructure | +| `all` | migrate, collector, api, web | Everything on one host | +| `core` | migrate, collector, api, web | Central server infrastructure | | `mqtt` | meshcore-mqtt-broker | Local MQTT broker (optional) | | `observer` | packet capture observer | Observes RF traffic and publishes to MQTT | | `seed` | seed | One-time seed data import | -| `migrate` | db-migrate | One-time database migration | +| `migrate` | migrate | One-time database migration | **Note:** Most deployments connect to an external MQTT broker. Add `--profile mqtt` only if you need a local broker. The `observer` profile runs [meshcore-packet-capture](https://github.com/agessaman/meshcore-packet-capture) to observe MeshCore RF traffic and publish decoded packets to MQTT. ```bash # Create database schema -docker compose -f docker-compose.yml -f docker-compose.dev.yml --profile migrate run --rm db-migrate +docker compose -f docker-compose.yml -f docker-compose.dev.yml --profile migrate run --rm migrate # Seed the database docker compose -f docker-compose.yml -f docker-compose.dev.yml --profile seed run --rm seed @@ -283,7 +283,7 @@ PACKETCAPTURE_MQTT3_TOKEN_AUDIENCE=mqtt.localhost make backup # Restore a specific volume -make restore FILE=backup/hub_hub_data-20260414-120000.tar.gz +make restore FILE=backup/hub_data-20260414-120000.tar.gz ``` #### Using shell commands @@ -292,13 +292,13 @@ make restore FILE=backup/hub_hub_data-20260414-120000.tar.gz # Back up the database volume source .env 2>/dev/null || true mkdir -p backup -vol=${COMPOSE_PROJECT_NAME:-hub}_hub_data +vol=${COMPOSE_PROJECT_NAME:-hub}_data docker run --rm -v $vol:/data -v $(pwd)/backup:/backup \ alpine tar czf /backup/$vol-$(date +%Y%m%d-%H%M%S).tar.gz -C / data # Restore a specific volume (volume name derived from tarball filename) source .env 2>/dev/null || true -FILE=backup/${COMPOSE_PROJECT_NAME:-hub}_hub_data-20260414-120000.tar.gz +FILE=backup/${COMPOSE_PROJECT_NAME:-hub}_data-20260414-120000.tar.gz vol=$(basename "$FILE" | sed 's/-[0-9]\{8\}-[0-9]\{6\}\.tar\.gz//') docker run --rm -v $vol:/data -v $(pwd)/backup:/backup \ alpine sh -c "cd / && tar xzf /backup/$(basename $FILE)" diff --git a/UPGRADING.md b/UPGRADING.md index b791940..89d7f1f 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -66,16 +66,16 @@ These volumes always need migrating: | Old Name | New Name | |----------|----------| -| `meshcore_hub_data` | `hub_hub_data` | +| `meshcore_hub_data` | `hub_data` | -> **Note:** `observer_data` and `mqtt_broker_data` are new — they are created automatically on first run and do not need migrating. Monitoring infrastructure (Prometheus, Alertmanager) is no longer bundled — if you used the previous `metrics` profile, manage those volumes separately. +> **Note:** `observer_data` and `mqtt_data` are new — they are created automatically on first run and do not need migrating. ### Option A: Rename (Docker Engine 23.0+) > **Note:** `docker volume rename` is not available in all Docker builds (e.g., Docker Desktop). If the command is not found, use Option B instead. ```bash -docker volume rename meshcore_hub_data hub_hub_data +docker volume rename meshcore_hub_data hub_data ``` ### Option B: Copy (all Docker versions) @@ -84,8 +84,8 @@ If `docker volume rename` is not available in your Docker build: ```bash # Create new volume, copy data, remove old -docker volume create hub_hub_data -docker run --rm -v meshcore_hub_data:/from -v hub_hub_data:/to alpine sh -c "cp -a /from/. /to/" +docker volume create hub_data +docker run --rm -v meshcore_hub_data:/from -v hub_data:/to alpine sh -c "cp -a /from/. /to/" # Verify the new volume has data, then remove old one docker volume rm meshcore_hub_data @@ -95,7 +95,7 @@ docker volume rm meshcore_hub_data > **Note:** If setting up a multi-instance deployment (e.g., `hub-prod`, `hub-beta`), use that project name instead of `hub`. -> **Note:** After migrating volumes, you may see warnings like `volume "hub_hub_data" already exists but was not created by Docker Compose. Use \`external: true\` to use an existing volume`. This is safe to ignore — it appears because the volumes were created manually during migration rather than by Docker Compose. Fresh deployments will not see this warning. +> **Note:** After migrating volumes, you may see warnings like `volume "hub_data" already exists but was not created by Docker Compose. Use \`external: true\` to use an existing volume`. This is safe to ignore — it appears because the volumes were created manually during migration rather than by Docker Compose. Fresh deployments will not see this warning. ## Step 4: Update Configuration Files @@ -182,13 +182,13 @@ All other `PACKETCAPTURE_*` variables have sensible defaults in `docker-compose. The migration renames `receiver_node_id` → `observer_node_id` across all event tables, `event_receivers` → `event_observers`, and `received_at` → `observed_at` in the event observers table: ```bash -docker compose -f docker-compose.yml -f docker-compose.dev.yml --profile core run --rm db-migrate +docker compose -f docker-compose.yml -f docker-compose.dev.yml --profile core run --rm migrate ``` This runs automatically as part of the `core` profile, but can also be run standalone with the `migrate` profile: ```bash -docker compose -f docker-compose.yml -f docker-compose.dev.yml --profile migrate run --rm db-migrate +docker compose -f docker-compose.yml -f docker-compose.dev.yml --profile migrate run --rm migrate ``` ## Step 7: Start Services diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 57c9299..eb44dd9 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -9,7 +9,7 @@ services: collector: depends_on: - db-migrate: + migrate: condition: service_completed_successfully mqtt: condition: service_healthy diff --git a/docker-compose.yml b/docker-compose.yml index f02b5c7..01d7361 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,7 +13,7 @@ services: - mqtt restart: unless-stopped volumes: - - mqtt_broker_data:/data + - mqtt_data:/data environment: # Broker listener - MQTT_WS_PORT=${MQTT_PORT:-1883} @@ -139,11 +139,11 @@ services: - all - core depends_on: - db-migrate: + migrate: condition: service_completed_successfully restart: unless-stopped volumes: - - hub_data:/data + - data:/data - ${SEED_HOME:-./seed}:/seed environment: - LOG_LEVEL=${LOG_LEVEL:-INFO} @@ -199,12 +199,12 @@ services: - core restart: unless-stopped depends_on: - db-migrate: + migrate: condition: service_completed_successfully collector: condition: service_started volumes: - - hub_data:/data + - data:/data environment: - LOG_LEVEL=${LOG_LEVEL:-INFO} - MQTT_HOST=${MQTT_HOST:-mqtt} @@ -304,19 +304,19 @@ services: # ========================================================================== # Database Migrations - Run Alembic migrations # ========================================================================== - db-migrate: + migrate: image: ghcr.io/ipnet-mesh/meshcore-hub:${IMAGE_VERSION:-latest} build: context: . dockerfile: Dockerfile - container_name: ${COMPOSE_PROJECT_NAME:-hub}-db-migrate + container_name: ${COMPOSE_PROJECT_NAME:-hub}-migrate profiles: - all - core - migrate restart: "no" volumes: - - hub_data:/data + - data:/data environment: - DATA_HOME=/data command: ["db", "upgrade"] @@ -337,7 +337,7 @@ services: - seed restart: "no" volumes: - - hub_data:/data + - data:/data - ${SEED_HOME:-./seed}:/seed:ro environment: - DATA_HOME=/data @@ -350,9 +350,9 @@ services: # Volumes # ========================================================================== volumes: - hub_data: - name: ${COMPOSE_PROJECT_NAME:-hub}_hub_data - mqtt_broker_data: - name: ${COMPOSE_PROJECT_NAME:-hub}_mqtt_broker_data + data: + name: ${COMPOSE_PROJECT_NAME:-hub}_data + mqtt_data: + name: ${COMPOSE_PROJECT_NAME:-hub}_mqtt_data observer_data: name: ${COMPOSE_PROJECT_NAME:-hub}_observer_data