Skip to content

Commit 92ad4ec

Browse files
committed
Add Docker support and update environment configuration
- Introduced .dockerignore to exclude unnecessary files from Docker builds. - Removed outdated .env.example file and updated README with Docker setup instructions. - Modified docker-publish.yml for improved image name handling. - Updated compose.yml for local image build and clarified environment variable usage. - Enhanced entrypoint.sh to support new environment variables. - Adjusted custom.css for better styling of filter labels.
1 parent 8ddc68e commit 92ad4ec

7 files changed

Lines changed: 82 additions & 43 deletions

File tree

.dockerignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
venv/
2+
.venv/
3+
__pycache__/
4+
*.pyc
5+
*.sqlite
6+
*.sqlite3
7+
.env
8+
*.log

.env.example

Lines changed: 0 additions & 9 deletions
This file was deleted.

.github/workflows/docker-publish.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ on:
88

99
env:
1010
REGISTRY: ghcr.io
11-
# IMAGE_NAME musi być małymi literami. github.repository może zawierać wielkie litery.
12-
# Dlatego w kroku budowania użyjemy metadanych, które to wyczyszczą.
11+
# IMAGE_NAME must be lowercase, otherwise the build will fail with "invalid reference format" error.
12+
# Therefore, in the build step, we will use metadata to clean it up.
1313
IMAGE_NAME: ${{ github.repository }}
1414

1515
jobs:
@@ -35,7 +35,7 @@ jobs:
3535
uses: docker/metadata-action@v5
3636
with:
3737
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
38-
# Akcja automatycznie zamienia nazwy obrazów na małe litery.
38+
# The action automatically converts image names to lowercase.
3939
tags: |
4040
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
4141
type=semver,pattern={{version}}
@@ -48,4 +48,3 @@ jobs:
4848
push: true
4949
tags: ${{ steps.meta.outputs.tags }}
5050
labels: ${{ steps.meta.outputs.labels }}
51-

README.md

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,6 @@ This will:
9090

9191
Stop the tool with `Ctrl+C`.
9292

93-
## Docker
94-
95-
You can use Meshcore Reachability as a Docker container.
96-
97-
Compose file is available in this repository. You can use it in Portainer Stack or directly using
98-
99-
```bash
100-
docker compose up -d
101-
```
102-
103-
Remember to set your env vars!
104-
10593
### Command line options
10694

10795
From `--help` in `meshcore_reachability.py`:
@@ -148,6 +136,49 @@ options:
148136

149137
> Note: `--headless` and `--guionly` are mutually exclusive. Do not enable both at the same time.
150138
139+
## Docker
140+
141+
MeshCore Reachability can be run as a Docker container using the included `compose.yml`.
142+
143+
### Setup
144+
145+
Open `compose.yml` and adjust the values in the `environment` section:
146+
147+
1. **Set your home location**`MC_LATITUDE` and `MC_LONGITUDE` are required.
148+
149+
2. **Set the connection to your LoRa device** — uncomment exactly one of:
150+
- `MC_SERIAL_PORT` for a USB serial connection — also uncomment the `devices` block directly above the `ports` entry so Docker can access the device:
151+
```yaml
152+
devices:
153+
- "/dev/ttyUSB0:/dev/ttyUSB0"
154+
```
155+
- `MC_HOST` for a TCP/IP connection (node must listen on port 5000)
156+
- `MC_BLE` for a BLE connection
157+
158+
3. Build and start:
159+
160+
```bash
161+
docker compose up -d
162+
```
163+
164+
The web UI is available at `http://localhost:5342`. The SQLite database is persisted in `/opt/meshcore-reachability/` on the host.
165+
166+
### Environment variables
167+
168+
| Variable | CLI equivalent | Description |
169+
|---|---|---|
170+
| `MC_SERIAL_PORT` | `-p` / `--port` | Serial port of the LoRa device (e.g. `/dev/ttyUSB0`) |
171+
| `MC_HOST` | `-ip` / `--host` | IP/hostname of the LoRa node (port 5000) |
172+
| `MC_BLE` | `--ble` | BLE address of the LoRa node |
173+
| `MC_LATITUDE` | `-lat` / `--latitude` | Latitude of home location |
174+
| `MC_LONGITUDE` | `-lon` / `--longitude` | Longitude of home location |
175+
| `MC_RADIUS_KM` | `-rad` / `--checkradius_km` | Check radius in km (default: 200) |
176+
| `MC_HEADLESS` | `--headless` | `true` = collect data without web UI |
177+
| `MC_GUIONLY` | `--guionly` | `true` = web UI only, no packet collection |
178+
| `MC_MAPTILER_KEY` | `-ak` / `--maptiler_api_key` | Optional MapTiler API key |
179+
180+
> Note: `MC_HEADLESS` and `MC_GUIONLY` are mutually exclusive.
181+
151182
---
152183

153184
## Database

assets/custom.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ html, body {
1919

2020
.reachable-filter {
2121
margin: 8px 0 16px 0;
22-
color: #f5f5f5;
2322
}
2423

2524
.reachable-filter input {
@@ -30,6 +29,7 @@ html, body {
3029
.reachable-filter label {
3130
margin-right: 12px;
3231
cursor: pointer;
32+
color: #f5f5f5;
3333
}
3434

3535
.map-container {

compose.yml

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,30 @@
11
services:
22
reachability:
3-
image: ghcr.io/usrflo/meshcore-reachability:latest
3+
# image: ghcr.io/usrflo/meshcore-reachability:latest
4+
build: .
5+
image: meshcore-reachability:local
46
container_name: meshcore-reachability
57
restart: unless-stopped
6-
# If using serial:
8+
# Serial port: uncomment both 'devices' and MC_SERIAL_PORT below, adjust the path:
79
# devices:
810
# - "/dev/ttyUSB0:/dev/ttyUSB0"
911
ports:
1012
- "5342:5342"
1113
environment:
12-
#- SERIAL_PORT=/dev/ttyUSB0
13-
- NODE_IP=192.168.253.162
14-
- LAT=51.1234 # Twoja szeroko..
15-
- LON=20.2233 # Twoja d.ugo..
16-
- RAD=25 # Promie. w km
17-
- MC_HEADLESS=false # Ustaw na true, je.li nie chcesz UI
18-
#- MC_MAPTILER_KEY=your_api_key
14+
# Connection — set exactly one of the three options:
15+
#- MC_SERIAL_PORT=/dev/ttyUSB0 # USB serial (also uncomment 'devices' above)
16+
#- MC_HOST=192.168.1.100 # TCP/IP (node must listen on port 5000)
17+
#- MC_BLE= # BLE address
18+
19+
# Required: home location
20+
- MC_LATITUDE=47.73322
21+
- MC_LONGITUDE=12.11043
22+
23+
# Optional
24+
- MC_RADIUS_KM=200 # Reachability check radius in km (default: 200)
25+
- MC_DB=/app/data/mcreach.sqlite # Database path inside the container
26+
#- MC_HEADLESS=false # true = collect data without web UI
27+
#- MC_GUIONLY=false # true = web UI only, no packet collection
28+
#- MC_MAPTILER_KEY= # MapTiler API key for background map tiles
1929
volumes:
20-
- /opt/meshcore-reachability:/app/data # Persist data
30+
- /opt/meshcore-reachability:/app/data # Persistent data (database)

entrypoint.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33

44
ARGS=""
55

6-
if [ -n "$SERIAL_PORT" ]; then ARGS="$ARGS -p $SERIAL_PORT"; fi
7-
if [ -n "$NODE_IP" ]; then ARGS="$ARGS -ip $NODE_IP"; fi
8-
if [ -n "$NODE_BLE" ]; then ARGS="$ARGS --ble $NODE_BLE"; fi
9-
if [ -n "$LAT" ]; then ARGS="$ARGS -lat $LAT"; fi
10-
if [ -n "$LON" ]; then ARGS="$ARGS -lon $LON"; fi
11-
if [ -n "$RAD" ]; then ARGS="$ARGS -rad $RAD"; fi
6+
if [ -n "$MC_SERIAL_PORT" ]; then ARGS="$ARGS -p $MC_SERIAL_PORT"; fi
7+
if [ -n "$MC_HOST" ]; then ARGS="$ARGS -ip $MC_HOST"; fi
8+
if [ -n "$MC_BLE" ]; then ARGS="$ARGS --ble $MC_BLE"; fi
9+
if [ -n "$MC_DB" ]; then ARGS="$ARGS --db $MC_DB"; fi
10+
if [ -n "$MC_LATITUDE" ]; then ARGS="$ARGS -lat $MC_LATITUDE"; fi
11+
if [ -n "$MC_LONGITUDE" ]; then ARGS="$ARGS -lon $MC_LONGITUDE"; fi
12+
if [ -n "$MC_RADIUS_KM" ]; then ARGS="$ARGS -rad $MC_RADIUS_KM"; fi
1213
if [ "$MC_HEADLESS" = "true" ]; then ARGS="$ARGS --headless"; fi
1314
if [ "$MC_GUIONLY" = "true" ]; then ARGS="$ARGS --guionly"; fi
1415
if [ -n "$MC_MAPTILER_KEY" ]; then ARGS="$ARGS -ak $MC_MAPTILER_KEY"; fi
1516

16-
# Uruchomienie aplikacji z przekazanymi argumentami
1717
exec python meshcore_reachability.py $ARGS

0 commit comments

Comments
 (0)