Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add target to run local scans #18

Merged
merged 1 commit into from
Aug 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ IMG ?= $(LATEST)

PLATFORMS ?= linux/amd64,linux/arm64

# Architecture, such as 'arm64'
ARCH := $(shell uname -m)
## LOCAL_ARCH is the architecture to be used for building components for local dev setups.
ifeq ($(ARCH),x86_64)
LOCAL_ARCH ?= amd64
else ifeq ($(ARCH),amd64)
LOCAL_ARCH ?= amd64
else ifeq ($(ARCH),arm64)
LOCAL_ARCH ?= arm64
endif

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
Expand Down Expand Up @@ -103,6 +114,13 @@ docker-build/%: docker-buildx ## Build docker image with ARCH as image tag suffi
--build-arg TARGETOS=$(DOCKER_OS) --build-arg TARGETARCH=$(DOCKER_ARCH) \
-t ${IMG}-${DOCKER_ARCH} --load .

.PHONY: scan-local
scan-local: IMG=local/kubegres:scan-${LOCAL_ARCH}
scan-local: build/linux/${LOCAL_ARCH} ## Scan the docker image for vulnerabilities locally.
docker context use default
docker build -t ${IMG} .
trivy image --severity "MEDIUM,HIGH,CRITICAL" ${IMG}

##@ Deployment

ifndef ignore-not-found
Expand Down
Loading