Get working with docker cli args

This commit is contained in:
Owen Schwartz
2024-09-29 15:14:23 -04:00
parent 8f7f2de645
commit d63ab8336e
5 changed files with 18 additions and 10 deletions

View File

@@ -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"]

View File

@@ -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:

View File

@@ -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

View File

@@ -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()