mirror of
https://github.com/fosrl/gerbil.git
synced 2026-02-21 04:16:41 +00:00
Get working with docker cli args
This commit is contained in:
@@ -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
|
# Set the working directory inside the container
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
@@ -16,14 +16,14 @@ COPY . .
|
|||||||
RUN CGO_ENABLED=0 GOOS=linux go build -o /gerbil
|
RUN CGO_ENABLED=0 GOOS=linux go build -o /gerbil
|
||||||
|
|
||||||
# Start a new stage from scratch
|
# 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/
|
WORKDIR /root/
|
||||||
|
|
||||||
# Copy the pre-built binary file from the previous stage
|
# Copy the pre-built binary file from the previous stage
|
||||||
COPY --from=build /gerbil .
|
COPY --from=builder /gerbil .
|
||||||
|
|
||||||
# Command to run the executable
|
# Command to run the executable
|
||||||
CMD ["./gerbil"]
|
CMD ["./gerbil"]
|
||||||
|
|||||||
7
Makefile
7
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
|
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o gerbil
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|||||||
@@ -4,13 +4,14 @@ services:
|
|||||||
gerbil:
|
gerbil:
|
||||||
image: gerbil
|
image: gerbil
|
||||||
container_name: gerbil
|
container_name: gerbil
|
||||||
|
command: ["./gerbil", "--config", "/config/gerbil.conf"]
|
||||||
cap_add:
|
cap_add:
|
||||||
- NET_ADMIN
|
- NET_ADMIN
|
||||||
- SYS_MODULE
|
- SYS_MODULE
|
||||||
volumes:
|
|
||||||
- ./config:/config
|
|
||||||
ports:
|
ports:
|
||||||
- 51820:51820/udp
|
- 51820:51820/udp
|
||||||
|
volumes:
|
||||||
|
- ./config_example.json:/config/config.json
|
||||||
sysctls:
|
sysctls:
|
||||||
- net.ipv4.conf.all.src_valid_mark=1
|
- net.ipv4.conf.all.src_valid_mark=1
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
4
main.go
4
main.go
@@ -19,7 +19,7 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
interfaceName = "wg0"
|
interfaceName = "wg0"
|
||||||
listenAddr = ":8080"
|
listenAddr = ":3002"
|
||||||
)
|
)
|
||||||
|
|
||||||
type WgConfig struct {
|
type WgConfig struct {
|
||||||
@@ -52,7 +52,7 @@ func main() {
|
|||||||
interfaceNameArg := flag.String("interface", "wg0", "Name of the WireGuard interface")
|
interfaceNameArg := flag.String("interface", "wg0", "Name of the WireGuard interface")
|
||||||
configFile := flag.String("config", "", "Path to local configuration file")
|
configFile := flag.String("config", "", "Path to local configuration file")
|
||||||
remoteConfigURL := flag.String("remoteConfig", "", "URL to fetch remote configuration")
|
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")
|
reportBandwidthTo := flag.String("reportBandwidthTo", "", "Address to listen on")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user