32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# 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(
image: image,
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, image)
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
|