11export DOCKER_BUILDKIT =1
22
3- NULL := /dev/null
4-
53# Pinned Versions
64SNYK_DESKTOP_VERSION := 1.332.0
75SNYK_USER_VERSION := 1.334.0
@@ -17,30 +15,8 @@ BUILD_ARGS := --build-arg SNYK_DESKTOP_VERSION=$(SNYK_DESKTOP_VERSION)\
1715 --build-arg ALPINE_VERSION=$(ALPINE_VERSION ) \
1816 --build-arg GOLANGCI_LINT_VERSION=$(GOLANGCI_LINT_VERSION )
1917
20- ifeq ($(COMMIT ) ,)
21- COMMIT := $(shell git rev-parse --short HEAD 2> $(NULL ) )
22- endif
23-
24- ifeq ($(TAG_NAME ) ,)
25- TAG_NAME := $(shell git describe --always --dirty --abbrev=10 2> $(NULL ) )
26- endif
27-
28- PKG_NAME =github.com/docker/docker-scan
29- STATIC_FLAGS = CGO_ENABLED=0
30- LDFLAGS := "-s -w \
31- -X $(PKG_NAME ) /internal.GitCommit=$(COMMIT ) \
32- -X $(PKG_NAME ) /internal.Version=$(TAG_NAME ) "
33-
34- GO_BUILD = $(STATIC_FLAGS ) go build -trimpath -ldflags=$(LDFLAGS )
35- BINARY =docker-scan
36-
3718.PHONY : build
38- build : # # Build docker-scan
39- mkdir -p bin
40- $(GO_BUILD ) -o bin/$(BINARY ) .
41-
42- .PHONY : dbuild
43- dbuild : # # Build docker-scan in a container
19+ build : # # Build docker-scan in a container
4420 docker build $(BUILD_ARGS ) . \
4521 --output type=local,dest=./bin \
4622 --target scan
@@ -51,35 +27,22 @@ cross: ## Cross compile docker-scan binaries in a container
5127 --output type=local,dest=./dist \
5228 --target cross
5329
54- dist : # # Build cross compiled docker-scan binaries
55- GOOS=linux GOARCH=amd64 $(GO_BUILD ) -o dist/docker-scan_linux_amd64/docker-scan/$(BINARY ) .
56- GOOS=darwin GOARCH=amd64 $(GO_BUILD ) -o dist/docker-scan_darwin_amd64/docker-scan/$(BINARY ) .
57- GOOS=windows GOARCH=amd64 $(GO_BUILD ) -o dist/docker-scan_windows_amd64/docker-scan/$(BINARY ) .exe .
58-
5930.PHONY : install
6031install : build # # Install docker-scan to your local cli-plugins directory
6132 cp bin/docker-scan ~ /.docker/cli-plugins
6233
6334.PHONY : e2e-build
64- e2e-build : # # Build e2e docker image
35+ e2e-build :
6536 docker build $(BUILD_ARGS ) . --target e2e -t docker-scan:e2e
6637
6738.PHONY : e2e
68- e2e : e2e-build
39+ e2e : e2e-build # # Run the end-to-end tests
6940 docker run --rm -v /var/run/docker.sock:/var/run/docker.sock docker-scan:e2e
7041
71- .PHONY : e2e-tests
72- e2e-tests :
73- go test -ldflags=$(LDFLAGS ) ./e2e
74-
7542.PHONY : lint
7643lint : # # Run the go linter
7744 @docker build . --target lint
7845
79- .PHONY : linter
80- linter :
81- golangci-lint run --timeout 10m0s ./...
82-
8346help : # # Show help
8447 @echo Please specify a build target. The choices are:
8548 @grep -E ' ^[0-9a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST ) | awk ' BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
0 commit comments