From bdfe1a5f008b424985cb09f9468c686cb2aac35d Mon Sep 17 00:00:00 2001 From: Alexis Fourmaux Date: Fri, 8 May 2026 12:38:40 +0200 Subject: [PATCH] fix: docker compose network config so that containers may communicate MQTT from gateway stack and app must be on the same network It was implied when they were from the same stack, but when splitting docker creates two default separated networks This commit creates a network for MQTT and makes the app join it Works only if the two stacks are on the same host (which is the case during development) --- app/docker-compose.yml | 8 +++++++- lora-gateway/docker-compose.yml | 23 +++++++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/app/docker-compose.yml b/app/docker-compose.yml index e7c249f..289317a 100644 --- a/app/docker-compose.yml +++ b/app/docker-compose.yml @@ -1,4 +1,10 @@ services: consumer: build: ./consumer - restart: unless-stopped \ No newline at end of file + restart: unless-stopped + networks: + - lora-gateway_mqtt + +networks: + lora-gateway_mqtt: + external: true \ No newline at end of file diff --git a/lora-gateway/docker-compose.yml b/lora-gateway/docker-compose.yml index 46bbbba..36d96c0 100644 --- a/lora-gateway/docker-compose.yml +++ b/lora-gateway/docker-compose.yml @@ -3,6 +3,10 @@ services: image: chirpstack/chirpstack:4 command: -c /etc/chirpstack restart: unless-stopped + ports: + - "8080:8080" + networks: + - internal volumes: - ./configuration/chirpstack:/etc/chirpstack depends_on: @@ -13,14 +17,14 @@ services: - MQTT_BROKER_HOST=mosquitto - REDIS_HOST=redis - POSTGRESQL_HOST=postgres - ports: - - "8080:8080" chirpstack-gateway-bridge: image: chirpstack/chirpstack-gateway-bridge:4 restart: unless-stopped ports: - "1700:1700/udp" + networks: + - internal volumes: - ./configuration/chirpstack-gateway-bridge:/etc/chirpstack-gateway-bridge environment: @@ -36,6 +40,8 @@ services: command: -c /etc/chirpstack-gateway-bridge/chirpstack-gateway-bridge-basicstation-eu868.toml ports: - "3001:3001" + networks: + - internal volumes: - ./configuration/chirpstack-gateway-bridge:/etc/chirpstack-gateway-bridge depends_on: @@ -47,6 +53,8 @@ services: command: --server chirpstack:8080 --bind 0.0.0.0:8090 --insecure ports: - "8090:8090" + networks: + - internal depends_on: - chirpstack @@ -56,6 +64,8 @@ services: volumes: - ./configuration/postgresql/initdb:/docker-entrypoint-initdb.d - db:/var/lib/postgresql + networks: + - internal environment: - POSTGRES_USER=chirpstack - POSTGRES_PASSWORD=chirpstack @@ -67,6 +77,8 @@ services: command: redis-server --save 300 1 --save 60 100 --appendonly no volumes: - redis:/data + networks: + - internal mosquitto: image: eclipse-mosquitto:2 @@ -75,7 +87,14 @@ services: - "1883:1883" volumes: - ./configuration/mosquitto/config/:/mosquitto/config/ + networks: + - internal + - mqtt volumes: db: redis: + +networks: + internal: + mqtt: