message: Add makefile variable to allow skipping trivy scanning when building images and disabled annoying "Use 'docker scan'..." messages
diff: @@ -53,6 +53,7 @@ SHELL := /bin/bash
  # Parameter for all `docker build` commands, can be overwritten by passing `DOCKER_BUILD_PARAMS=` via the `-e` option
  DOCKER_BUILD_PARAMS := --quiet
  +DOCKER_SCAN_SUGGEST := DOCKER
  # On CI systems like jenkins we need a way to run multiple testings at the same time. We expect the
  # CI systems to define an Environment variable CI_BUILD_TAG which uniquely identifies each build.
  @@ -92,6 +93,9 @@ K3D_NAME := k3s-$(shell echo $(CI_BUILD_TAG) | sed -E 's/.*(.{31})$$/\1/')
  BRANCH_NAME := $(shell git rev-parse --abbrev-ref HEAD)
  SAFE_BRANCH_NAME := $(shell echo $(BRANCH_NAME) | sed -E 's:/:_:g')
  +# Skip image scanning to make building images substantially faster
  +SKIP_SCAN := false
  +
  # Init the file that is used to hold the image tag cross-reference table
  $(shell >build.txt)
  $(shell >scan.txt)
  @@ -102,9 +106,15 @@ $(shell >scan.txt)
  # Builds a docker image. Expects as arguments: name of the image, location of Dockerfile, path of
  # Docker Build Context
  -docker_build = docker build $(DOCKER_BUILD_PARAMS) --build-arg LAGOON_VERSION=$(LAGOON_VERSION) --build-arg IMAGE_REPO=$(CI_BUILD_TAG) --build-arg UPSTREAM_REPO=$(UPSTREAM_REPO) --build-arg UPSTREAM_TAG=$(UPSTREAM_TAG) -t $(CI_BUILD_TAG)/$(1) -f $(2) $(3)
  +docker_build = DOCKER_SCAN_SUGGEST=false docker build $(DOCKER_BUILD_PARAMS) --build-arg LAGOON_VERSION=$(LAGOON_VERSION) --build-arg IMAGE_REPO=$(CI_BUILD_TAG) --build-arg UPSTREAM_REPO=$(UPSTREAM_REPO) --build-arg UPSTREAM_TAG=$(UPSTREAM_TAG) -t $(CI_BUILD_TAG)/$(1) -f $(2) $(3)
  +
  +scan_cmd = docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v $(HOME)/Library/Caches:/root/.cache/ aquasec/trivy --timeout 5m0s $(CI_BUILD_TAG)/$(1) >> scan.txt
  -scan_image = docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v $(HOME)/Library/Caches:/root/.cache/ aquasec/trivy --timeout 5m0s $(CI_BUILD_TAG)/$(1) >> scan.txt
  +ifeq ($(SKIP_SCAN),false)
  + scan_image = $(scan_cmd)
  +else
  + scan_image =
  +endif
  # Tags an image with the `testlagoon` repository and pushes it
  docker_publish_testlagoon = docker tag $(CI_BUILD_TAG)/$(1) testlagoon/$(2) && docker push testlagoon/$(2) | cat
  