Sha256: 2dd9662d525fad4c0191efd12fcd172673c4208318304b533a1f2296fcc40229

Contents?: true

Size: 1.09 KB

Versions: 9

Compression:

Stored size: 1.09 KB

Contents

class KuberKit::ImageCompiler::ImageBuildDirCreator
  include KuberKit::Import[
    "preprocessing.dir_preprocessor",
    "preprocessing.file_preprocessor",
    "shell.bash_commands",
    "configs"
  ]

  Contract KuberKit::Shell::AbstractShell, KuberKit::Core::Image, String, KeywordArgs[
    context_helper: Maybe[Any]
  ] => Any
  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
      dir_preprocessor.compile(
        shell, image.build_context_dir, build_dir,
        context_helper: context_helper
      )
    end

    target_dockerfile = File.join(build_dir, configs.image_dockerfile_name)
    file_preprocessor.compile(
      shell, image.dockerfile_path, 
      destination_path: 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

  def cleanup(shell, build_dir)
    bash_commands.rm_rf(shell, build_dir)
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
kuber_kit-0.1.8 lib/kuber_kit/image_compiler/image_build_dir_creator.rb
kuber_kit-0.1.7 lib/kuber_kit/image_compiler/image_build_dir_creator.rb
kuber_kit-0.1.6 lib/kuber_kit/image_compiler/image_build_dir_creator.rb
kuber_kit-0.1.5 lib/kuber_kit/image_compiler/image_build_dir_creator.rb
kuber_kit-0.1.4 lib/kuber_kit/image_compiler/image_build_dir_creator.rb
kuber_kit-0.1.3 lib/kuber_kit/image_compiler/image_build_dir_creator.rb
kuber_kit-0.1.2 lib/kuber_kit/image_compiler/image_build_dir_creator.rb
kuber_kit-0.1.1 lib/kuber_kit/image_compiler/image_build_dir_creator.rb
kuber_kit-0.1.0 lib/kuber_kit/image_compiler/image_build_dir_creator.rb