module Docker::Template::Cache

Public Instance Methods

aliased_context(builder) click to toggle source

– rubocop:disable Metrics/LineLength –

# File lib/docker/template/cache.rb, line 31
def aliased_context(builder)
  if builder.aliased_repo.cache_dir.exist?
    $stderr.puts Simple::Ansi.yellow(format("Copying %s context to %s", builder.aliased_repo, builder.repo))
    builder.aliased_repo.cache_dir.cp_r(builder.repo.cache_dir.tap(
      &:rm_rf
    ))
  end
end
cleanup(repo) click to toggle source

– Cleanup the context caches, removing the caches we no longer need. rubocop:enable Metrics/LineLength –

# File lib/docker/template/cache.rb, line 45
def cleanup(repo)
  return unless repo.clean_cache?
  cache_dir = repo.cache_dir.parent

  if cache_dir.exist?
    cache_dir.children.each do |file|
      next unless repo.meta.tags.include?(file.basename)
      $stdout.puts Simple::Ansi.yellow(format("Removing %s.",
        file.relative_path_from(Template.root)
      ))

      file.rm_rf
    end
  end
end
context(builder, context) click to toggle source

Cache the context into the cache directory. –

# File lib/docker/template/cache.rb, line 14
def context(builder, context)
  builder.repo.cache_dir.rm_rf
  $stderr.puts Simple::Ansi.yellow(format("Copying context for %s", builder.repo))
  cache_dir = builder.repo.cache_dir
  cache_dir.parent.mkdir_p

  context.cp_r(cache_dir.tap(
    &:rm_rf
  ))

  readme(builder)
end
readme(builder) click to toggle source

– Note: We normally expect but do not require you to have a README. Search for and copy the readme if available. –

# File lib/docker/template/cache.rb, line 66
def readme(builder)
  return unless file = builder.repo.root.children.find { |val| val =~ /readme/i }
  file.safe_copy(builder.repo.cache_dir, {
    :root => file.parent
  })
end