class Indocker::Images::ImageCompiler
Constants
- BUILDS_DIR
- DOCKERIGNORE
Public Class Methods
new()
click to toggle source
# File lib/indocker/images/image_compiler.rb, line 18 def initialize @compiled_images = Hash.new(false) end
Public Instance Methods
compile(build_context, image, skip_dependent)
click to toggle source
# File lib/indocker/images/image_compiler.rb, line 22 def compile(build_context, image, skip_dependent) if !skip_dependent image.dependent_images.each do |dependent_image| compile_image(build_context, dependent_image) end end compile_image(build_context, image) end
compile_image(build_context, image)
click to toggle source
# File lib/indocker/images/image_compiler.rb, line 32 def compile_image(build_context, image) return if @compiled_images[image] compile_dir = File.join(build_context.configuration.build_dir, BUILDS_DIR, image.name.to_s) FileUtils.rm_rf(compile_dir) FileUtils.mkdir_p(compile_dir) if image.build_context templates_compiler = Indocker::Images::TemplatesCompiler.new templates_compiler.compile( templates_dir: image.build_context, compile_dir: compile_dir, context: build_context ) end compiler = Indocker::Images::TemplateCompiler.new target_dockerfile = File.join(compile_dir, 'Dockerfile') FileUtils.cp(image.dockerfile, target_dockerfile) compiler.compile(target_dockerfile, build_context) File .join(compile_dir, '.dockerignore') .tap { |_| File.write(_, Indocker.dockerignore.join("\n")) } if image.before_build image.before_build.call(build_context, compile_dir) end build_context.build_image(image, compile_dir) @compiled_images[image] = true end