Skip to content

Commit

Permalink
Add a Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
dpup committed Sep 9, 2024
1 parent 278b0c3 commit 4fb43dd
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 14 deletions.
29 changes: 29 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
**/.DS_Store
**/__pycache__
**/.venv
**/.classpath
**/.dockerignore
**/.env
**/.envrc
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/bin
**/charts
**/docker-compose*
**/compose.y*ml
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
ARG PYTHON_VERSION=3.12.5
FROM python:${PYTHON_VERSION}-slim AS base

ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

WORKDIR /app

ARG UID=10001
RUN adduser \
--disabled-password \
--gecos "" \
--home "/nonexistent" \
--shell "/sbin/nologin" \
--no-create-home \
--uid "${UID}" \
appuser

RUN --mount=type=cache,target=/root/.cache/pip \
--mount=type=bind,source=requirements.txt,target=requirements.txt \
python -m pip install -r requirements.txt

USER appuser
COPY . .

ENTRYPOINT python3 -m check-mate
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ Run check-mate:

### Arguments

| Arg | Description |
| ------------- | ------------------------------------------------------------------ |
| -h | Show help |
| --host | The IP or hostname of the meshtastic node, e.g. `192.168.5.10` |
| --location | Text description of where your node is, e.g. `SF Mission District` |
| --healthcheck | URL to send healthcheck pings to when receiving messages |
| Arg | Env | Description |
| ------------- | -------------- | ------------------------------------------------------------------ |
| -h | N/A | Show help |
| --host | HOST | The IP or hostname of the meshtastic node, e.g. `192.168.5.10` |
| --location | LOCATION | Text description of where your node is, e.g. `SF Mission District` |
| --healthcheck | HEALTHCHECKURL | URL to send healthcheck pings to when receiving messages |

## Example radio check

Expand Down
26 changes: 18 additions & 8 deletions check-mate.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import argparse
import logging
import os
import random
import re
import requests
Expand Down Expand Up @@ -135,15 +136,16 @@ def getMessage(self, snr, rssi, name):
"""generate a random message to respond to a radio check"""
if self.location:
loc = self.location
quality = f"({rssi} RSSI, {snr} SNR)"
messages = [
f"{name}, read you 5 by 5 from {loc} ({rssi} RSSI, {snr} SNR)",
f"👋 {name}, got you from {loc}",
f"{name}, read you 5 by 5 from {loc} {quality}",
f"👋 {name}, got you from {loc} {quality}",
f"Copy {name}, {snr} SNR & {rssi} RSSI from {loc}",
f"Hey {name}, message received from {loc} ({rssi} RSSI, {snr} SNR)",
f"{name}, loud and clear from {loc} ({rssi} RSSI, {snr} SNR)",
f"{name}, copy your radio check from {loc}",
f"{name}, copy from {loc} ({rssi} RSSI, {snr} SNR)",
f"{name}, copy {snr} SNR from {loc}",
f"Hey {name}, message received from {loc} {quality}",
f"{name}, loud and clear from {loc} {quality}",
f"{name}, copy your radio check from {loc} {quality}",
f"{name}, copy from {loc} {quality}",
f"{name}, copy {snr} SNR & {rssi} RSSI from {loc}",
]
else:
messages = [
Expand Down Expand Up @@ -221,23 +223,31 @@ def idToHex(self, nodeId):
parser.add_argument(
"--host",
dest="host",
required=True,
required=False,
help="IP or hostname for Meshtastic device",
default=os.environ.get("HOST"),
)
parser.add_argument(
"-l",
"--location",
dest="location",
required=False,
help="Location to report in radio checks",
default=os.environ.get("LOCATION"),
)
parser.add_argument(
"--healthcheck",
dest="healthCheckURL",
required=False,
help="URL to report healthchecks to (empty HEAD request)",
default=os.environ.get("HEALTHCHECKURL"),
)
args = parser.parse_args()

if not args.host:
parser.error(
"Please provide a host via --host or the $HOST environment variable"
)

checkmate = CheckMate(args.host, args.location, args.healthCheckURL)
sys.exit(checkmate.start())
5 changes: 5 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
services:
server:
build:
context: .
dockerfile: Dockerfile

0 comments on commit 4fb43dd

Please sign in to comment.