From c160c9af055c26a9cfd877874e15299f1712fa3a Mon Sep 17 00:00:00 2001 From: root Date: Sat, 9 May 2026 22:18:14 +0200 Subject: [PATCH 1/8] Initial Dockerfile --- Dockerfile | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2462b84 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +# Dockerfile +FROM python:3.11-slim + +# Ustawienie katalogu roboczego +WORKDIR /app + +# Instalacja zależności systemowych (np. dla komunikacji szeregowej lub kompilacji) +RUN apt-get update && apt-get install -y --no-install-recommends \ + gcc \ + python3-dev \ + && rm -rf /var/lib/apt/lists/* + +# Kopiowanie plików zależności (jeśli istnieją) +COPY requirements.txt* ./ +RUN if [ -f requirements.txt ]; then pip install --no-cache-dir -r requirements.txt; fi + +# Kopiowanie reszty kodu aplikacji +COPY . . + +# Domyślny punkt wejścia - dostosuj nazwę pliku (np. reachability.py) +# Jeśli aplikacja to moduł, użyj: CMD ["python", "-m", "nazwa_modulu"] +ENTRYPOINT ["python"] +CMD ["reachability.py"] + From 7b372e59f00abd13b2561a083412fd49ad862442 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 9 May 2026 22:28:15 +0200 Subject: [PATCH 2/8] Docker --- Dockerfile | 14 +++++--------- entrypoint.sh | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 9 deletions(-) create mode 100644 entrypoint.sh diff --git a/Dockerfile b/Dockerfile index 2462b84..721f3bb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,20 @@ -# Dockerfile FROM python:3.11-slim -# Ustawienie katalogu roboczego WORKDIR /app -# Instalacja zależności systemowych (np. dla komunikacji szeregowej lub kompilacji) +# Deps RUN apt-get update && apt-get install -y --no-install-recommends \ gcc \ python3-dev \ && rm -rf /var/lib/apt/lists/* -# Kopiowanie plików zależności (jeśli istnieją) COPY requirements.txt* ./ RUN if [ -f requirements.txt ]; then pip install --no-cache-dir -r requirements.txt; fi -# Kopiowanie reszty kodu aplikacji COPY . . -# Domyślny punkt wejścia - dostosuj nazwę pliku (np. reachability.py) -# Jeśli aplikacja to moduł, użyj: CMD ["python", "-m", "nazwa_modulu"] -ENTRYPOINT ["python"] -CMD ["reachability.py"] +# Perms +RUN chmod +x entrypoint.sh +# Entrypoint +ENTRYPOINT ["./entrypoint.sh"] diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..645fd4b --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,17 @@ +#!/bin/bash +# entrypoint.sh + +ARGS="" + +if [ -n "$SERIAL_PORT" ]; then ARGS="$ARGS -p $SERIAL_PORT"; fi +if [ -n "$NODE_IP" ]; then ARGS="$ARGS -ip $NODE_IP"; fi +if [ -n "$NODE_BLE" ]; then ARGS="$ARGS --ble $NODE_BLE"; fi +if [ -n "$LAT" ]; then ARGS="$ARGS -lat $LAT"; fi +if [ -n "$LON" ]; then ARGS="$ARGS -lon $LON"; fi +if [ -n "$RAD" ]; then ARGS="$ARGS -rad $RAD"; fi +if [ "$MC_HEADLESS" = "true" ]; then ARGS="$ARGS --headless"; fi +if [ "$MC_GUIONLY" = "true" ]; then ARGS="$ARGS --guionly"; fi +if [ -n "$MC_MAPTILER_KEY" ]; then ARGS="$ARGS -ak $MC_MAPTILER_KEY"; fi + +# Uruchomienie aplikacji z przekazanymi argumentami +exec python meshcore_reachability.py $ARGS From d506eb069b23687856314dab82214112e16b09d2 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 9 May 2026 22:30:19 +0200 Subject: [PATCH 3/8] GHCR --- .github/workflows/docker-publish.yml | 43 ++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/docker-publish.yml diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..49c481b --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,43 @@ +name: Docker Build and Push + +on: + push: + branches: [ "main", "master" ] + tags: [ 'v*.*.*' ] + workflow_dispatch: + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} From 8bb40852bcc4ceae50c82e8a5fb93aede1319551 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 9 May 2026 22:37:44 +0200 Subject: [PATCH 4/8] Env Example --- .env.example | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..666089a --- /dev/null +++ b/.env.example @@ -0,0 +1,9 @@ +#SERIAL_PORT = /dev/ttyUSB0 +NODE_IP = 192.168.253.162 +#NODE_BLE = +LAT = 47.73322 +LON = 12.11043 +RAD = 30 +# MC_HEADLESS = true +# MC_GUIONLY = true +#MC_MAPTILER_KEY = From e1b9a41ccd0a7c0967ada86c819c6dab9cf632d1 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 9 May 2026 22:48:03 +0200 Subject: [PATCH 5/8] Docker build --- .github/workflows/docker-publish.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 49c481b..f44b25e 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -8,6 +8,7 @@ on: env: REGISTRY: ghcr.io + # Używamy github.repository, ale metadata-action zadba o małe litery IMAGE_NAME: ${{ github.repository }} jobs: @@ -33,6 +34,14 @@ jobs: uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + # Konfiguracja tagów + tags: | + type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }} + type=semver,pattern={{version}} + type=sha,format=short + # Wymuszenie małych liter w nazwie obrazu (wymóg GHCR) + flavor: | + lower=true - name: Build and push Docker image uses: docker/build-push-action@v5 From 829dd00944ca52080affeee111055eed7c9107d5 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 9 May 2026 22:50:08 +0200 Subject: [PATCH 6/8] Build --- .github/workflows/docker-publish.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index f44b25e..c045c90 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -8,7 +8,8 @@ on: env: REGISTRY: ghcr.io - # Używamy github.repository, ale metadata-action zadba o małe litery + # IMAGE_NAME musi być małymi literami. github.repository może zawierać wielkie litery. + # Dlatego w kroku budowania użyjemy metadanych, które to wyczyszczą. IMAGE_NAME: ${{ github.repository }} jobs: @@ -34,14 +35,11 @@ jobs: uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - # Konfiguracja tagów + # Akcja automatycznie zamienia nazwy obrazów na małe litery. tags: | type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }} type=semver,pattern={{version}} type=sha,format=short - # Wymuszenie małych liter w nazwie obrazu (wymóg GHCR) - flavor: | - lower=true - name: Build and push Docker image uses: docker/build-push-action@v5 @@ -50,3 +48,4 @@ jobs: push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + From 5848ea75348d501abbc064b0093eb4a0a1c5f8eb Mon Sep 17 00:00:00 2001 From: root Date: Sat, 9 May 2026 23:19:23 +0200 Subject: [PATCH 7/8] Compose --- compose.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 compose.yml diff --git a/compose.yml b/compose.yml new file mode 100644 index 0000000..96a98e4 --- /dev/null +++ b/compose.yml @@ -0,0 +1,20 @@ +services: + reachability: + image: ghcr.io/usrflo/meshcore-reachability:latest + container_name: meshcore-reachability + restart: unless-stopped + # If using serial: + # devices: + # - "/dev/ttyUSB0:/dev/ttyUSB0" + ports: + - "5342:5342" + environment: + #- SERIAL_PORT=/dev/ttyUSB0 + - NODE_IP=192.168.253.162 + - LAT=51.1234 # Twoja szeroko.. + - LON=20.2233 # Twoja d.ugo.. + - RAD=25 # Promie. w km + - MC_HEADLESS=false # Ustaw na true, je.li nie chcesz UI + #- MC_MAPTILER_KEY=your_api_key + volumes: + - /opt/meshcore-reachability:/app/data # Persist data \ No newline at end of file From 8ddc68e01951c5e18e2b7b5d97ff1c5637bfcd6f Mon Sep 17 00:00:00 2001 From: root Date: Sat, 9 May 2026 23:24:18 +0200 Subject: [PATCH 8/8] README Update --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 84da19e..b2248f2 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,18 @@ This will: Stop the tool with `Ctrl+C`. +## Docker + +You can use Meshcore Reachability as a Docker container. + +Compose file is available in this repository. You can use it in Portainer Stack or directly using + +```bash +docker compose up -d +``` + +Remember to set your env vars! + ### Command line options From `--help` in `meshcore_reachability.py`: