-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmakefile
59 lines (42 loc) · 2.05 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
59
.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 api
swag init -g cmd/soarca/main.go -o api
lint: swagger
golangci-lint run --timeout 5m -v
build: swagger
CGO_ENABLED=0 go build -o ./build/soarca $(GOFLAGS) ./cmd/soarca/main.go
test: swagger
go test ./pkg/... -v
go test ./internal/... -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) cmd/soarca/main.go
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o bin/${BINARY_NAME}-${VERSION}-darwin-arm64 $(GOFLAGS) cmd/soarca/main.go
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o bin/${BINARY_NAME}-${VERSION}-windows-amd64 $(GOFLAGS) cmd/soarca/main.go
sbom: swagger
echo "Generating SBOMs"
mkdir -p bin
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 cyclonedx-gomod app -main cmd/soarca -json -licenses -output bin/${BINARY_NAME}-${VERSION}-linux-amd64.bom.json
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 cyclonedx-gomod app -main cmd/soarca -json -licenses -output bin/${BINARY_NAME}-${VERSION}-darwin-amd64.bom.json
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 cyclonedx-gomod app -main cmd/soarca -json -licenses -output bin/${BINARY_NAME}-${VERSION}-windows-amd64.bom.json
pre-docker-build: swagger
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/${BINARY_NAME}-${VERSION}-linux-amd64 $(GOFLAGS) cmd/soarca/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