class KuberKit::ImageCompiler::ImageBuildDirCreator

Public Instance Methods

cleanup(shell, build_dir) click to toggle source
# File lib/kuber_kit/image_compiler/image_build_dir_creator.rb, line 40
def cleanup(shell, build_dir)
  bash_commands.rm_rf(shell, build_dir)
end
create(shell, image, build_dir, context_helper: nil) click to toggle source
# File lib/kuber_kit/image_compiler/image_build_dir_creator.rb, line 12
def create(shell, image, build_dir, context_helper: nil)
  bash_commands.rm_rf(shell, build_dir)
  bash_commands.mkdir_p(shell, build_dir)

  if image.build_context_dir
    # Sync build context and then preprocess
    shell.sync(image.build_context_dir, build_dir)

    shell.recursive_list_files(build_dir).each do |file_path|
      file_preprocessor.compile(
        shell, file_path, 
        context_helper: context_helper
      )
    end
  end

  # Sync dockerfile and then preprocess
  target_dockerfile = File.join(build_dir, configs.image_dockerfile_name)
  shell.sync(image.dockerfile_path, target_dockerfile)
  file_preprocessor.compile(
    shell, target_dockerfile,
    context_helper: context_helper
  )

  docker_ignore_content = configs.docker_ignore_list.join("\r\n")
  shell.write(File.join(build_dir, '.dockerignore'), docker_ignore_content)
end