Skip to content

Commit

Permalink
Add docker builder for the wag binary (debian 11)
Browse files Browse the repository at this point in the history
  • Loading branch information
NHAS committed Dec 23, 2022
1 parent 09188a6 commit 6434de5
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 111 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ LDFLAGS += -X 'github.com/NHAS/wag/config.Version=$(shell git describe --tags)'
LDFLAGS_RELEASE = $(LDFLAGS) -s -w

debug: .generate_ebpf
CGO_ENABLED=0 go build -ldflags="$(LDFLAGS)"
go build -ldflags="$(LDFLAGS)"

release: .generate_ebpf
CGO_ENABLED=0 go build -ldflags="$(LDFLAGS_RELEASE)"
go build -ldflags="$(LDFLAGS_RELEASE)"

.generate_ebpf:
BPF_CLANG=clang BPF_CFLAGS='-O2 -g -Wall -Werror' go generate ./...
BPF_CLANG=clang BPF_CFLAGS='-O2 -g -Wall -Werror' go generate ./...
13 changes: 13 additions & 0 deletions builder/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM debian:bullseye
RUN apt update -y
RUN apt upgrade -y
RUN apt install -y make wget llvm clang gcc git
RUN wget https://go.dev/dl/go1.19.4.linux-amd64.tar.gz
RUN rm -rf /usr/local/go && tar -C /usr/local -xzf go1.19.4.linux-amd64.tar.gz
ENV PATH="$PATH:/usr/local/go/bin"
RUN mkdir -p /build/
WORKDIR /build
ADD build-wag.sh .
RUN chmod +x build-wag.sh
ENTRYPOINT ["bash", "/build/build-wag.sh"]

9 changes: 9 additions & 0 deletions builder/build-wag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

if [[ ! -d /wag ]]; then
echo "/wag not present, please mount folder onto docker container with -v"
exit 1
fi

cd /wag
make release
4 changes: 2 additions & 2 deletions data/db_migrations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/NHAS/wag/config"
"github.com/NHAS/wag/data/migrations"
_ "modernc.org/sqlite"
_ "github.com/mattn/go-sqlite3"
)

func TestMigrationFromNew(t *testing.T) {
Expand All @@ -26,7 +26,7 @@ func TestMigrationFromVersion1(t *testing.T) {
t.Fatal(err)
}

db, err := sql.Open("sqlite", "file::memory:?cache=shared")
db, err := sql.Open("sqlite3", "file::memory:?cache=shared")
if err != nil {
t.Fatal(err)
}
Expand Down
4 changes: 2 additions & 2 deletions data/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"time"

"github.com/NHAS/wag/data/migrations"
_ "modernc.org/sqlite"
_ "github.com/mattn/go-sqlite3"
)

var (
Expand Down Expand Up @@ -43,7 +43,7 @@ func copyFile(src, dst string) error {

func Load(path string) error {

db, err := sql.Open("sqlite", path)
db, err := sql.Open("sqlite3", path)
if err != nil {
return err
}
Expand Down
26 changes: 13 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
module github.com/NHAS/wag

go 1.17
go 1.19

require (
github.com/cilium/ebpf v0.9.3
github.com/coreos/go-iptables v0.6.0
github.com/mattn/go-sqlite3 v1.14.16
github.com/mdlayher/netlink v1.7.1
github.com/pquerna/otp v1.4.0
golang.org/x/net v0.4.0
Expand All @@ -14,29 +15,28 @@ require (
)

require (
github.com/boombuler/barcode v1.0.1 // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/josharian/native v1.1.0 // indirect
github.com/josharian/native v1.0.0 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/mdlayher/genetlink v1.3.1 // indirect
github.com/mdlayher/genetlink v1.2.0 // indirect
github.com/mdlayher/socket v0.4.0 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20220927061507-ef77025ab5aa // indirect
golang.org/x/crypto v0.4.0 // indirect
golang.org/x/mod v0.7.0 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect
golang.org/x/crypto v0.1.0 // indirect
golang.org/x/mod v0.3.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/tools v0.4.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
golang.org/x/tools v0.0.0-20201124115921-2c860bdd6e78 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
golang.zx2c4.com/wireguard v0.0.0-20220920152132-bb719d3a6e2c // indirect
lukechampine.com/uint128 v1.2.0 // indirect
modernc.org/cc/v3 v3.40.0 // indirect
modernc.org/ccgo/v3 v3.16.13 // indirect
modernc.org/libc v1.22.2 // indirect
modernc.org/libc v1.21.5 // indirect
modernc.org/mathutil v1.5.0 // indirect
modernc.org/memory v1.5.0 // indirect
modernc.org/memory v1.4.0 // indirect
modernc.org/opt v0.1.3 // indirect
modernc.org/strutil v1.1.3 // indirect
modernc.org/token v1.1.0 // indirect
modernc.org/token v1.0.1 // indirect
)
95 changes: 4 additions & 91 deletions go.sum

Large diffs are not rendered by default.

Binary file modified router/bpf_bpfeb.o
Binary file not shown.
Binary file modified router/bpf_bpfel.o
Binary file not shown.

0 comments on commit 6434de5

Please sign in to comment.