Add container build + rename project
All checks were successful
/ build-container (push) Successful in 1m52s

This commit is contained in:
Finn 2024-10-20 21:44:55 -07:00
parent 7362eb4546
commit b1b518e146
6 changed files with 49 additions and 6 deletions

View file

@ -0,0 +1,29 @@
on: [push]
jobs:
build-container:
runs-on: docker
container:
image: library/docker:dind
steps:
- run: apk add --no-cache nodejs git
- name: login to container registry
run: echo "${{ secrets.PACKAGE_PUBLISH_TOKEN }}" | docker login --username finn --password-stdin git.janky.solutions
- name: gather metadata for container image tags
uses: https://github.com/docker/metadata-action@v5
id: meta
with:
images: git.janky.solutions/finn/matrix-bridge-meshtastic
tags: |
type=schedule
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=ref,event=branch
type=sha
- name: build container image
uses: docker/build-push-action@v6
with:
file: Containerfile
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: ${{ github.ref == 'refs/heads/main' }}

4
.gitignore vendored
View file

@ -1,2 +1,2 @@
matrix-meshtastic-bridge.json
matrix-meshtastic-bridge.db
matrix-bridge-meshtastic.json
matrix-bridge-meshtastic.db

8
Containerfile Normal file
View file

@ -0,0 +1,8 @@
FROM library/golang:1.23 AS build
ADD . /bridge
WORKDIR /bridge
RUN go build ./cmd/matrix-bridge-meshtastic
FROM gcr.io/distroless/base-debian12:nonroot
COPY --from=build /bridge/matrix-bridge-meshtastic /usr/bin/matrix-bridge-meshtastic
ENTRYPOINT ["/usr/bin/matrix-bridge-meshtastic"]

View file

@ -89,10 +89,9 @@ func handlePacket(ctx context.Context, packet *protobufs.MeshPacket) error {
sourceString = fmt.Sprintf("%x", packet.From)
}
logrus.WithField("source", sourceString).Debug("handling incoming meshtastic node")
switch payload.Decoded.Portnum {
case protobufs.PortNum_TEXT_MESSAGE_APP:
logrus.WithField("source", sourceString).Info("handling incoming meshtastic -> matrix message")
return matrix.SendMessage(ctx, fmt.Sprintf("text from %s: %s (snr: %f, rssi: %d, hop limit: %d, hop start: %d)", sourceString, payload.Decoded.Payload, packet.RxSnr, packet.RxRssi, packet.HopLimit, packet.HopStart))
default:
logrus.WithField("type", protobufs.PortNum_name[int32(payload.Decoded.Portnum)]).Debug("ignoring unknown app payload")

View file

@ -28,7 +28,7 @@ type Matrix struct {
}
var C = Config{
Database: "matrix-meshtastic-bridge.db",
Database: "matrix-bridge-meshtastic.db",
Meshtastic: Meshtastic{
RequestTimeout: time.Second * 5,
PollingInterval: time.Millisecond * 500,
@ -36,7 +36,14 @@ var C = Config{
}
func Load() error {
return load("matrix-meshtastic-bridge.json")
for _, filename := range []string{"/etc/matrix-bridge-meshtastic.json", "matrix-bridge-meshtastic.json"} {
err := load(filename)
if err != nil && !os.IsNotExist(err) {
return err
}
}
return nil
}
func load(filename string) error {