forked from COSSAS/SOARCA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
58 lines (41 loc) · 1.89 KB
/
makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
.PHONY: all test integration-test ci-test clean build docker run pre-docker-build swagger sbom
BINARY_NAME=soarca
DIRECTORY = $(sort $(dir $(wildcard ./test/*/)))
VERSION = $(shell git describe --tags --dirty)
BUILDTIME := $(shell date '+%Y-%m-%dT%T%z')
GOLDFLAGS += -X main.Version=$(VERSION)
GOLDFLAGS += -X main.Buildtime=$(BUILDTIME)
GOFLAGS = -ldflags "$(GOLDFLAGS)"
swagger:
mkdir -p swaggerdocs
swag init -o swaggerdocs
lint: swagger
golangci-lint run --timeout 5m -v
build: swagger
CGO_ENABLED=0 go build -o ./build/soarca $(GOFLAGS) main.go
test:
go test ./test/unittest/... -v
integration-test: swagger
go test ./test/integration/... -v
ci-test: test integration-test
clean:
rm -rf build/soarca* build/main
rm -rf bin/*
compile: swagger
echo "Compiling for every OS and Platform"
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/${BINARY_NAME}-${VERSION}-linux-amd64 $(GOFLAGS) main.go
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o bin/${BINARY_NAME}-${VERSION}-darwin-arm64 $(GOFLAGS) main.go
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o bin/${BINARY_NAME}-${VERSION}-windows-amd64 $(GOFLAGS) main.go
sbom:
echo "Generating SBOMs"
mkdir -p bin
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 cyclonedx-gomod app -json -licenses -output bin/${BINARY_NAME}-${VERSION}-linux-amd64.bom.json
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 cyclonedx-gomod app -json -licenses -output bin/${BINARY_NAME}-${VERSION}-darwin-amd64.bom.json
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 cyclonedx-gomod app -json -licenses -output bin/${BINARY_NAME}-${VERSION}-windows-amd64.bom.json
pre-docker-build: swagger
GOOS=linux GOARCH=amd64 go build -o bin/${BINARY_NAME}-${VERSION}-linux-amd64 $(GOFLAGS) main.go
docker: pre-docker-build
docker build --no-cache -t soarca:${VERSION} --build-arg="VERSION=${VERSION}" .
run: docker
GIT_VERSION=${VERSION} docker compose up --build --force-recreate -d
all: build