Add Dockerfile
This commit is contained in:
parent
100d70dccf
commit
ca0e81eaa1
3 changed files with 40 additions and 11 deletions
12
Dockerfile
Normal file
12
Dockerfile
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
FROM golang:alpine AS builder
|
||||||
|
WORKDIR /go/src/jrouter
|
||||||
|
COPY . .
|
||||||
|
RUN --mount=type=cache,target=/root/.cache/go-build \
|
||||||
|
--mount=type=cache,target=/go/pkg/mod \
|
||||||
|
apk add build-base libpcap-dev && \
|
||||||
|
CGO_ENABLED=1 CGO_FLAGS='-static' go build -v -o jrouter .
|
||||||
|
|
||||||
|
FROM alpine:latest
|
||||||
|
COPY --from=builder /go/src/jrouter/jrouter /usr/bin/
|
||||||
|
RUN apk add libpcap
|
||||||
|
ENTRYPOINT ["/usr/bin/jrouter", "-config", "/etc/jrouter/jrouter.yaml"]
|
32
README.md
32
README.md
|
@ -37,7 +37,7 @@ Things I plan to fix Real Soon Now:
|
||||||
|
|
||||||
Things I plan to fix At Some Point:
|
Things I plan to fix At Some Point:
|
||||||
|
|
||||||
* For expediency I made it act as a _seed router_. At some point I might add
|
* For expediency I made it act as a _seed router_. At some point I might add
|
||||||
"soft seed" functionality.
|
"soft seed" functionality.
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,20 +49,16 @@ First, set up a `jrouter.yaml` (use the one in this repo as an example).
|
||||||
|
|
||||||
TODO: explain the configuration file
|
TODO: explain the configuration file
|
||||||
|
|
||||||
Building and running:
|
### Building and running directly
|
||||||
|
|
||||||
1. Install [Go](https://go.dev/dl).
|
1. Install [Go](https://go.dev/dl).
|
||||||
|
|
||||||
2. Run these commands (for Debian-variety Linuxen, e.g. Ubuntu, Raspbian, Mint...):
|
2. Run these commands (for Debian-variety Linuxen, e.g. Ubuntu, Raspbian, Mint...):
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
sudo apt install git build-essential libpcap-dev
|
sudo apt install git build-essential libpcap-dev
|
||||||
go install gitea.drjosh.dev/josh/jrouter@latest
|
go install gitea.drjosh.dev/josh/jrouter@latest
|
||||||
sudo setcap 'CAP_NET_BIND_SERVICE=ep CAP_NET_RAW=ep' ~/go/bin/jrouter
|
sudo setcap 'CAP_NET_BIND_SERVICE=ep CAP_NET_RAW=ep' ~/go/bin/jrouter
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Configure `jrouter.yaml`
|
3. Configure `jrouter.yaml`
|
||||||
|
|
||||||
4. To run:
|
4. To run:
|
||||||
```shell
|
```shell
|
||||||
~/go/bin/jrouter
|
~/go/bin/jrouter
|
||||||
|
@ -77,6 +73,26 @@ Notes:
|
||||||
|
|
||||||
TODO: instructions for non-Linux / non-Debian-like machines
|
TODO: instructions for non-Linux / non-Debian-like machines
|
||||||
|
|
||||||
## Bug reports? Feature requests? Complaints? Praise?
|
### With Docker
|
||||||
|
|
||||||
You can contact me on the Fediverse at @DrJosh9000@cloudisland.nz, or email me at josh.deprez@gmail.com.
|
1. Clone the repo and `cd` into it.
|
||||||
|
2. `docker build -t jrouter .`
|
||||||
|
3. Example `docker run` command:
|
||||||
|
```shell
|
||||||
|
docker run \
|
||||||
|
-v ./cfg:/etc/jrouter \
|
||||||
|
--cap-add NET_RAW \
|
||||||
|
--net host \
|
||||||
|
--name jrouter \
|
||||||
|
jrouter
|
||||||
|
```
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
|
||||||
|
* Put `jrouter.yaml` inside a `cfg` directory (or some path of your choice and bind-mount it at `/etc/jrouter`) for it to find the config file.
|
||||||
|
* `--cap-add NET_RAW` and `--net host` is needed for EtherTalk access to the network interface.
|
||||||
|
* By using `--net host`, the default AURP port (387) will be bound without `-p`.
|
||||||
|
|
||||||
|
## Bug reports? Feature requests? Complaints? Praise?
|
||||||
|
|
||||||
|
You can contact me on the Fediverse at @DrJosh9000@cloudisland.nz, or email me at josh.deprez@gmail.com.
|
||||||
|
|
7
main.go
7
main.go
|
@ -30,7 +30,6 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"regexp"
|
"regexp"
|
||||||
"runtime/debug"
|
|
||||||
"slices"
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
@ -104,7 +103,7 @@ const peerTableTemplate = `
|
||||||
<td>{{$peer.LastReconnectAgo}}</td>
|
<td>{{$peer.LastReconnectAgo}}</td>
|
||||||
<td>{{$peer.LastUpdateAgo}}</td>
|
<td>{{$peer.LastUpdateAgo}}</td>
|
||||||
<td>{{$peer.LastSendAgo}}</td>
|
<td>{{$peer.LastSendAgo}}</td>
|
||||||
<td>{{$peer.SendRetries}}</td>
|
<td>{{$peer.SendRetries}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{end}}
|
{{end}}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@ -117,7 +116,9 @@ var configFilePath = flag.String("config", "jrouter.yaml", "Path to configuratio
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// For some reason it occasionally panics and the panics have no traceback?
|
// For some reason it occasionally panics and the panics have no traceback?
|
||||||
debug.SetTraceback("all")
|
// This didn't help:
|
||||||
|
// debug.SetTraceback("all")
|
||||||
|
// I think it's calling recover in a defer too broadly.
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
log.Println("jrouter")
|
log.Println("jrouter")
|
||||||
|
|
Loading…
Reference in a new issue