wagoodman / dive

A tool for exploring each layer in a docker image
MIT License
47.48k stars 1.79k forks source link

[Feature Request] - Specify files to ignore for calculations in CI #347

Open serg-kovalev opened 3 years ago

serg-kovalev commented 3 years ago

I want to specify which binaries (or any other files) should be excluded from checks/calculations/verifications

Example:

Analyzing image...
  efficiency: 61.7012 %
  wastedBytes: 41314421 bytes (41 MB)
  userWastedPercent: 85.4058 %
Inefficient Files:
Count  Wasted Space  File Path
    2         24 MB  /path/binary_1
    2         17 MB  /path/binary_2
   ....
Results:
  FAIL: highestUserWastedPercent: too many bytes wasted, relative to the user bytes added (%-user-wasted-bytes=0.8540577136942192 > threshold=0.2)
  FAIL: highestWastedBytes: too many bytes wasted (wasted-bytes=41314421 > threshold=20000000)
  FAIL: lowestEfficiency: image efficiency is too low (efficiency=0.6170116079613327 < threshold=0.95)
Result:FAIL [Total:3] [Passed:0] [Failed:3] [Warn:0] [Skipped:0]

My Docker image is based on alpine, so generated binaries (which are mandatory "assets" of my image) should be excluded from checks having an option in config file.

my .dive-ci:

rules:
  # If the efficiency is measured below X%, mark as failed.
  # Expressed as a ratio between 0-1.
  lowestEfficiency: 0.95

  # If the amount of wasted space is at least X or larger than X, mark as failed.
  # Expressed in B, KB, MB, and GB.
  highestWastedBytes: 20MB

  # If the amount of wasted space makes up for X% or more of the image, mark as failed.
  # Note: the base image layer is NOT included in the total image size.
  # Expressed as a ratio between 0-1; fails if the threshold is met or crossed.
  highestUserWastedPercent: 0.20