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"]
|
26
README.md
26
README.md
|
@ -49,20 +49,16 @@ First, set up a `jrouter.yaml` (use the one in this repo as an example).
|
|||
|
||||
TODO: explain the configuration file
|
||||
|
||||
Building and running:
|
||||
### Building and running directly
|
||||
|
||||
1. Install [Go](https://go.dev/dl).
|
||||
|
||||
2. Run these commands (for Debian-variety Linuxen, e.g. Ubuntu, Raspbian, Mint...):
|
||||
|
||||
```shell
|
||||
sudo apt install git build-essential libpcap-dev
|
||||
go install gitea.drjosh.dev/josh/jrouter@latest
|
||||
sudo setcap 'CAP_NET_BIND_SERVICE=ep CAP_NET_RAW=ep' ~/go/bin/jrouter
|
||||
```
|
||||
|
||||
3. Configure `jrouter.yaml`
|
||||
|
||||
4. To run:
|
||||
```shell
|
||||
~/go/bin/jrouter
|
||||
|
@ -77,6 +73,26 @@ Notes:
|
|||
|
||||
TODO: instructions for non-Linux / non-Debian-like machines
|
||||
|
||||
### With Docker
|
||||
|
||||
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.
|
||||
|
|
5
main.go
5
main.go
|
@ -30,7 +30,6 @@ import (
|
|||
"os"
|
||||
"os/signal"
|
||||
"regexp"
|
||||
"runtime/debug"
|
||||
"slices"
|
||||
"strings"
|
||||
"sync"
|
||||
|
@ -117,7 +116,9 @@ var configFilePath = flag.String("config", "jrouter.yaml", "Path to configuratio
|
|||
|
||||
func main() {
|
||||
// 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()
|
||||
log.Println("jrouter")
|
||||
|
|
Loading…
Reference in a new issue