File tree Expand file tree Collapse file tree 3 files changed +37
-3
lines changed
Expand file tree Collapse file tree 3 files changed +37
-3
lines changed Original file line number Diff line number Diff line change 1+ name : build
2+
3+ on :
4+ push :
5+ branches : [main]
6+ pull_request :
7+ branches : [main]
8+
9+ jobs :
10+ build :
11+ runs-on : ubuntu-latest
12+ steps :
13+ - uses : actions/checkout@v2
14+ - uses : actions/setup-go@v2
15+ with :
16+ go-version : " 1.17"
17+ - name : Build
18+ run : make docker-bin
19+ env :
20+ DOCKER_BUILDKIT : 1
21+ COMPOSE_DOCKER_CLI_BUILD : 1
22+ - name : Test
23+ run : make docker-test
24+ env :
25+ DOCKER_BUILDKIT : 1
26+ COMPOSE_DOCKER_CLI_BUILD : 1
Original file line number Diff line number Diff line change @@ -24,7 +24,8 @@ RUN git clone --branch libpcap-1.10.1 --depth 1 https://github.com/the-tcpdump-g
2424COPY . /src
2525WORKDIR /src
2626ARG RELEASE=0
27- RUN make build STATIC=1 RELEASE=${RELEASE}
27+ RUN --mount=type=cache,target=/root/.cache/go-build \
28+ make build STATIC=1 RELEASE=${RELEASE}
2829
2930FROM alpine:3.15 as packetstreamer
3031
Original file line number Diff line number Diff line change 11IMAGE ?= docker.io/deepfenceio/deepfence_packetstreamer
2+ IMAGE_BUILD ?= docker.io/deepfenceio/deepfence_packetstreamer_build
23CC ?= gcc
34LDFLAGS ?=
5+ TAGS ?=
46STATIC ?= 0
57ifeq ($(STATIC ) ,1)
68 LDFLAGS += -linkmode external -extldflags "-static"
9+ TAGS += musl
710endif
811RELEASE ?= 0
912ifeq ($(RELEASE ) ,1)
1518all : build
1619
1720build :
18- go build --ldflags ' $(LDFLAGS)' -o packetstreamer ./main.go
21+ go build -tags ' $(TAGS) ' - -ldflags ' $(LDFLAGS)' -o packetstreamer ./main.go
1922
2023docker-bin : docker-image
2124 docker cp $(shell docker create --rm $(IMAGE ) ) :/usr/bin/packetstreamer .
@@ -26,5 +29,9 @@ docker-image:
2629docker-push :
2730 docker push $(IMAGE )
2831
32+ docker-test :
33+ docker build -t $(IMAGE_BUILD ) --target builder .
34+ docker run --rm $(IMAGE_BUILD ) make test STATIC=1
35+
2936test :
30- go test ./...
37+ go test -tags ' $(TAGS) ' ./...
You can’t perform that action at this time.
0 commit comments