Class: KuberKit::ImageCompiler::ImageBuildDirCreator

Inherits:
Object
  • Object
show all
Defined in:
lib/kuber_kit/image_compiler/image_build_dir_creator.rb

Instance Method Summary collapse

Instance Method Details

#cleanup(shell, build_dir) ⇒ Object



34
35
36
# File 'lib/kuber_kit/image_compiler/image_build_dir_creator.rb', line 34

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

#create(shell, image, build_dir, context_helper: nil) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# 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
    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