Class: Dash::Dockerfile::Rules::NoCacheMount

Inherits:
Base
  • Object
show all
Defined in:
lib/dash/dockerfile/rules/no_cache_mount.rb

Overview

Without a cache mount, an install that misses the layer cache downloads every package again. With one, it reuses whatever the last build left behind.

Instance Method Summary collapse

Instance Method Details

#findings ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/dash/dockerfile/rules/no_cache_mount.rb', line 4

def findings
  document.instructions.filter_map do |instruction|
    next unless installs?(instruction)
    next if Array(instruction.flags["mount"]).any? { |mount| mount.include?("type=cache") }

    note at(instruction), "#{command_for(instruction)} runs without a cache mount, so a cache miss downloads everything again",
      "add --mount=type=cache,target=#{target_for(instruction)}"
  end
end