13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/indocker/build_context.rb', line 13
def build_image(image, build_dir, args: [])
image_name = image.image_name
registry = image.registry
tag = image.tag
FileUtils.cd(build_dir) do
if @logger.debug?
@logger.debug("#{"Docker image content:".yellow}")
Dir[File.join(build_dir, '*')]
.map {|path|
file = path.gsub(build_dir, '')
@logger.debug(" .#{file}".yellow)
}
.join("\n")
end
if !@logger.debug?
args = args.push('-q')
end
build_args = args.join(' ')
res = Indocker::Docker.build(image.local_registry_url, build_args)
if res.exit_status != 0
@global_logger.error("image compilation :#{image.name} failed")
@global_logger.error(res.stdout)
exit 1
end
Indocker::Docker.tag(image.local_registry_url, image.registry_url)
if image.registry_url != image.local_registry_url
Indocker::Docker.tag(image.local_registry_url, image.local_registry_url)
end
if !image.registry.is_local?
Indocker::Docker.push(image.registry_url)
end
end
end
|