-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
71 lines (60 loc) · 1.86 KB
/
Copy pathMakefile
File metadata and controls
71 lines (60 loc) · 1.86 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
BUILD_DATE ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
IMAGE_NAME ?= filastudio/laravel-vigil-scanner
LDFLAGS := -w -s \
-X github.com/filastudio/laravel-vigil-scanner/cmd.Version=$(VERSION) \
-X github.com/filastudio/laravel-vigil-scanner/cmd.Commit=$(COMMIT) \
-X github.com/filastudio/laravel-vigil-scanner/cmd.BuildDate=$(BUILD_DATE)
.PHONY: all build install clean test docker-build docker-push docker-run
## Build the binary
build:
go build -ldflags="$(LDFLAGS)" -o vigil .
## Install to GOPATH/bin
install:
go install -ldflags="$(LDFLAGS)" .
## Run tests
test:
go test ./...
## Clean build artifacts
clean:
rm -f vigil vigil-report.* reports/
## Build Docker image
docker-build:
docker build \
--build-arg VERSION=$(VERSION) \
--build-arg COMMIT=$(COMMIT) \
--build-arg BUILD_DATE=$(BUILD_DATE) \
-t $(IMAGE_NAME):$(VERSION) \
-t $(IMAGE_NAME):latest \
.
## Push Docker image to DockerHub
docker-push: docker-build
docker push $(IMAGE_NAME):$(VERSION)
docker push $(IMAGE_NAME):latest
## Run a scan using Docker (set PROJECT_PATH to your Laravel project)
docker-run:
docker run --rm \
-v "$(PROJECT_PATH):/app:ro" \
$(IMAGE_NAME):latest \
scan . $(ARGS)
## Build multi-platform Docker image and push
docker-buildx:
docker buildx build \
--platform linux/amd64,linux/arm64 \
--build-arg VERSION=$(VERSION) \
--build-arg COMMIT=$(COMMIT) \
--build-arg BUILD_DATE=$(BUILD_DATE) \
-t $(IMAGE_NAME):$(VERSION) \
-t $(IMAGE_NAME):latest \
--push \
.
## Show help
help:
@echo "Laravel Vigil — Makefile targets:"
@echo ""
@grep -E '^## ' $(MAKEFILE_LIST) | sed 's/## / /'
@echo ""
@echo "Variables:"
@echo " VERSION = $(VERSION)"
@echo " IMAGE_NAME = $(IMAGE_NAME)"