From 6beb90fe2752cd6523016b6817498bedc416c110 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Tue, 25 Jun 2024 14:37:19 +0200 Subject: [PATCH 1/2] Update readme for better markdown syntax --- README.md | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 739a284..64b4e76 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # OS2IoT-docker -This repository contains the docker-compose file and configuration needed to run the OS2IoT project. +This repository contains the docker compose file and configuration needed to run the OS2IoT project. Documentation is available at: https://os2iot.readthedocs.io/en/latest/ @@ -17,8 +17,8 @@ OS2IoT From the `OS2IoT-docker` folder in a suitable terminal use: -``` -docker-compose up +```shell +docker compose up ``` ## Configuration @@ -28,7 +28,7 @@ Edit the files in the configuration folder to adjust settings for each requireme ## Contents - Postgres from the official image. -- Chirpstack using their docker-compose +- Chirpstack using their docker compose ## Troubleshooting FAQ @@ -58,19 +58,25 @@ error: database "os2iot-e2e" does not exist ``` Cause: + Database has not been setup correctly on local machine. Solution: -docker-compose down --volumes + +```shell +docker compose down --volumes dos2unix configuration/os2iot-postgresql/initdb/\* <-- Skal køres fra git bash -docker-compose up +docker compose up +``` ### error: Error: connect ETIMEDOUT xxx.xxx.xxx.xxx:xxxx at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16) Cause: + Docker is trying to connect to the wrong ip. Solution: + 1. Navigate to hosts file: C:\Windows\System32\drivers\etc 2. Open hosts file as administrator 3. Change related ip of host.docker.internal and gateway.docker.internal to your new ip (found in terminal using the ipconfig command: e.g. 192.168.0.1) @@ -78,6 +84,7 @@ Solution: 5. restart the application. ## Adding an ADR Algorithm + When the ADR Algorithm has been tested, and is ready for deployment, the ADR Algorithm has to be added to chirpstack. It is mandatory that the custom adr module is writtin in js. ## Adding the Plugin to Chirpstack @@ -89,6 +96,7 @@ Therefore a new folder can be added such as `./configuration/chirpstack/adr-modu This makes the file available at `/etc/chirpstack/adr-modules/example-file.js` within the chirpstack container. The last step is to specify the file as being an adr-plugin within the `chirpstack.toml` config file by adding `adr_plugins=["/etc/chirpstack/adr-modules/example-file.js"]` under `[network]`, like this: + ```toml [network] adr_plugins=["/etc/chirpstack/adr-modules/example-file.js"] @@ -103,7 +111,7 @@ When hosting via helm the steps are slightly different. 1. Make sure that the persistent volume claim belonging to the chirpstack exists in your hosted setup. 2. Find the actual name of the network-server pod. This can be done in a few ways. If you're have a connection via a GUI like `Lens` it can be found under the `Pods` list. If you're hosting on an Azure Kubernetes service, it can be found under the side menu `Workloads -> Pods` 3. Use `kubectl` to copy the module into the pod - ```bash + ```shell kubectl cp ./path/to/module/adr-module chirpstack-xxxxxxxxx-xxxxx:/etc/chirpstack/adr-modules ``` 4. Update `configmap.yaml` located under `/helm/charts/chirpstack/templates` with the path to the plugin under `[network]`, like this: From d96e7135d8a3c60a2a8986929cd59df8bcfaf5b5 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Tue, 25 Jun 2024 14:38:19 +0200 Subject: [PATCH 2/2] Update docker compose for consistency and stop exposing ports to local network --- docker-compose.yml | 62 ++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 830fc1b..9376097 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -version: "3.8" - services: #Chirpstack chirpstack-network-server: @@ -10,14 +8,14 @@ services: chirpstack-application-server: image: chirpstack/chirpstack-application-server:3.17.9 ports: - - 8084:8080 + - '8080' volumes: - ./configuration/chirpstack-application-server:/etc/chirpstack-application-server chirpstack-gateway-bridge: image: chirpstack/chirpstack-gateway-bridge:4.0.10 ports: - - 1700:1700/udp + - '1700/udp' volumes: - ./configuration/chirpstack-gateway-bridge:/etc/chirpstack-gateway-bridge @@ -27,14 +25,14 @@ services: volumes: - ./configuration/chirpstack:/etc/chirpstack ports: - - 8080:8080 + - '8080' postgresql: image: postgres:9.6-alpine environment: - POSTGRES_PASSWORD=root ports: - - 5434:5432 + - '5432' volumes: - ./configuration/postgresql/initdb:/docker-entrypoint-initdb.d - postgresqldata:/var/lib/postgresql/data @@ -47,30 +45,30 @@ services: environment: - POSTGRES_PASSWORD=root ports: - - 5435:5432 + - '5432' redis: image: redis:5-alpine volumes: - redisdata:/data ports: - - 6379:6379 + - '6379' mosquitto: image: eclipse-mosquitto:2 ports: - - 1883:1883 + - '1883' volumes: - ./configuration/eclipse-mosquitto/mosquitto.conf:/mosquitto/config/mosquitto.conf #OS2IoT os2iot-frontend: - image: "os2iot-frontend" + image: os2iot-frontend build: - context: "../OS2IoT-frontend" - dockerfile: "Dockerfile-prod" + context: ../OS2IoT-frontend + dockerfile: Dockerfile-prod ports: - - "8081:8081" + - '8081' environment: PRODUCTION: "false" BASE_URL: http://localhost:3000/api/v1/ @@ -78,23 +76,23 @@ services: #OS2IoT os2iot-lorawanSimulator: - image: "os2iot-lorawan_simulator" + image: os2iot-lorawan_simulator build: - context: "./simulator" - dockerfile: "Dockerfile" + context: ./simulator + dockerfile: Dockerfile ports: - - "8768:8000" + - '8000' os2iot-backend: - image: "os2iot-backend" + image: os2iot-backend build: context: ../OS2IoT-backend dockerfile: Dockerfile target: prod ports: - - 3000:3000 + - '3000' healthcheck: - test: ["CMD", "curl", "-f", "http://localhost:3000/status"] + test: ["CMD", "curl", "-f", "http://os2iot-backend:3000/status"] interval: 10s timeout: 5s retries: 5 @@ -130,7 +128,7 @@ services: restart: always image: postgis/postgis # We need postgis to store geodata ports: - - 5433:5432 + - '5432' hostname: os2iot-pg healthcheck: test: ["CMD-SHELL", "pg_isready -U os2iot"] @@ -146,20 +144,20 @@ services: - pg-data:/var/lib/postgresql:Z os2iot-zookeeper: - image: "bitnami/zookeeper:latest" + image: bitnami/zookeeper:latest ports: - - "2181:2181" + - '2181' environment: - ALLOW_ANONYMOUS_LOGIN=yes volumes: - os2iot-zookeeperdata:/data - tmpfs: "/datalog" + tmpfs: /datalog os2iot-kafka: - image: "bitnami/kafka:latest" + image: bitnami/kafka:latest ports: - - "9092:9092" - - "9093:9093" + - '9092' + - '9093' environment: - KAFKA_BROKER_ID=1 - KAFKA_LISTENERS=PLAINTEXT://:9092,INTERNAL://:9093 @@ -174,12 +172,12 @@ services: mosquitto-os2iot: image: os2iot-mosquitto - ports: - - 8884:8884 - - 8885:8885 build: - context: "./mosquitto-broker" - dockerfile: "Dockerfile" + context: ./mosquitto-broker + dockerfile: Dockerfile + ports: + - '8884' + - '8885' volumes: - ./configuration/mosquitto-broker-os2iot/ca.crt:/etc/mosquitto/ca_certificates/ca.crt - ./configuration/mosquitto-broker-os2iot/ca.key:/etc/mosquitto/ca_certificates/ca.key