diff --git a/Dockerfile b/Dockerfile index c4f40f0..24322cf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.21.5-alpine AS build +FROM golang:1.21.5-alpine AS builder # Set the working directory inside the container WORKDIR /app @@ -16,14 +16,14 @@ COPY . . RUN CGO_ENABLED=0 GOOS=linux go build -o /gerbil # Start a new stage from scratch -FROM ubuntu:22:04 +FROM ubuntu:22.04 AS runner -RUN RUN apt-get update && apt-get install -y nftables && apt-get clean +RUN apt-get update && apt-get install -y nftables && apt-get clean WORKDIR /root/ # Copy the pre-built binary file from the previous stage -COPY --from=build /gerbil . +COPY --from=builder /gerbil . # Command to run the executable CMD ["./gerbil"] diff --git a/Makefile b/Makefile index 2b790d2..040cf93 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,11 @@ -all: + +all: + docker build -t gerbil . + +test: + docker run -it -p 3002:3002 -v ./config_example.json:/config/config.json --cap-add=NET_ADMIN --cap-add=SYS_MODULE gerbil ./gerbil --config /config/config.json + +local: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o gerbil clean: diff --git a/config_exmaple.json b/config_example.json similarity index 100% rename from config_exmaple.json rename to config_example.json diff --git a/docker-compose.yml b/docker-compose.yml index 7f9305a..1a73de3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,13 +4,14 @@ services: gerbil: image: gerbil container_name: gerbil + command: ["./gerbil", "--config", "/config/gerbil.conf"] cap_add: - NET_ADMIN - SYS_MODULE - volumes: - - ./config:/config ports: - 51820:51820/udp + volumes: + - ./config_example.json:/config/config.json sysctls: - net.ipv4.conf.all.src_valid_mark=1 - restart: unless-stopped + restart: unless-stopped \ No newline at end of file diff --git a/main.go b/main.go index 0a96874..219a8ab 100644 --- a/main.go +++ b/main.go @@ -19,7 +19,7 @@ import ( var ( interfaceName = "wg0" - listenAddr = ":8080" + listenAddr = ":3002" ) type WgConfig struct { @@ -52,7 +52,7 @@ func main() { interfaceNameArg := flag.String("interface", "wg0", "Name of the WireGuard interface") configFile := flag.String("config", "", "Path to local configuration file") remoteConfigURL := flag.String("remoteConfig", "", "URL to fetch remote configuration") - listenAddrArg := flag.String("listen", ":8080", "Address to listen on") + listenAddrArg := flag.String("listen", ":3002", "Address to listen on") reportBandwidthTo := flag.String("reportBandwidthTo", "", "Address to listen on") flag.Parse()