6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/djin/interpreter/docker_command_builder.rb', line 6
def call(params, task_name:)
current_folder_name = Pathname.getwd.basename.to_s
image = params['image'] || "djin_#{current_folder_name}_#{task_name}"
build_params = params['build']
if build_params.is_a?(Hash)
build_context = build_params['context']
build_options = build_params['options']
end
build_context ||= build_params
run_command, run_options = build_run_params(params['run'])
command = %(docker run #{run_options} #{image} sh -c "#{run_command}").squeeze(' ')
build_command = "docker build #{build_context} #{build_options} -t #{image}".squeeze(' ') if build_context
[command, build_command]
end
|