Add container build + rename project
All checks were successful
/ build-container (push) Successful in 1m52s
All checks were successful
/ build-container (push) Successful in 1m52s
This commit is contained in:
parent
7362eb4546
commit
b1b518e146
6 changed files with 49 additions and 6 deletions
29
.forgejo/workflows/container-build.yaml
Normal file
29
.forgejo/workflows/container-build.yaml
Normal 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
4
.gitignore
vendored
|
@ -1,2 +1,2 @@
|
||||||
matrix-meshtastic-bridge.json
|
matrix-bridge-meshtastic.json
|
||||||
matrix-meshtastic-bridge.db
|
matrix-bridge-meshtastic.db
|
||||||
|
|
8
Containerfile
Normal file
8
Containerfile
Normal 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"]
|
|
@ -89,10 +89,9 @@ func handlePacket(ctx context.Context, packet *protobufs.MeshPacket) error {
|
||||||
sourceString = fmt.Sprintf("%x", packet.From)
|
sourceString = fmt.Sprintf("%x", packet.From)
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.WithField("source", sourceString).Debug("handling incoming meshtastic node")
|
|
||||||
|
|
||||||
switch payload.Decoded.Portnum {
|
switch payload.Decoded.Portnum {
|
||||||
case protobufs.PortNum_TEXT_MESSAGE_APP:
|
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))
|
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:
|
default:
|
||||||
logrus.WithField("type", protobufs.PortNum_name[int32(payload.Decoded.Portnum)]).Debug("ignoring unknown app payload")
|
logrus.WithField("type", protobufs.PortNum_name[int32(payload.Decoded.Portnum)]).Debug("ignoring unknown app payload")
|
||||||
|
|
|
@ -28,7 +28,7 @@ type Matrix struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
var C = Config{
|
var C = Config{
|
||||||
Database: "matrix-meshtastic-bridge.db",
|
Database: "matrix-bridge-meshtastic.db",
|
||||||
Meshtastic: Meshtastic{
|
Meshtastic: Meshtastic{
|
||||||
RequestTimeout: time.Second * 5,
|
RequestTimeout: time.Second * 5,
|
||||||
PollingInterval: time.Millisecond * 500,
|
PollingInterval: time.Millisecond * 500,
|
||||||
|
@ -36,7 +36,14 @@ var C = Config{
|
||||||
}
|
}
|
||||||
|
|
||||||
func Load() error {
|
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 {
|
func load(filename string) error {
|
||||||
|
|
Loading…
Reference in a new issue