lib/kitchen/docker/helpers/image_helper.rb in kitchen-docker-2.13.0 vs lib/kitchen/docker/helpers/image_helper.rb in kitchen-docker-2.14.0
- old
+ new
@@ -11,10 +11,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
require 'kitchen'
require 'kitchen/configurable'
+require 'pathname'
require_relative 'cli_helper'
require_relative 'container_helper'
module Kitchen
module Docker
@@ -23,11 +24,11 @@
include Configurable
include Kitchen::Docker::Helpers::CliHelper
include Kitchen::Docker::Helpers::ContainerHelper
def parse_image_id(output)
- output.each_line do |line|
+ output.split("\n").reverse_each do |line|
if line =~ /writing image (sha256:[[:xdigit:]]{64})(?: \d*\.\ds)? done/i
img_id = line[/writing image (sha256:[[:xdigit:]]{64})(?: \d*\.\ds)? done/i,1]
return img_id
end
if line =~ /image id|build successful|successfully built/i
@@ -48,10 +49,10 @@
cmd << ' --no-cache' unless config[:use_cache]
cmd << " --platform=#{config[:docker_platform]}" if config[:docker_platform]
extra_build_options = config_to_options(config[:build_options])
cmd << " #{extra_build_options}" unless extra_build_options.empty?
dockerfile_contents = dockerfile
- file = Tempfile.new('Dockerfile-kitchen', Dir.pwd)
+ file = Tempfile.new('Dockerfile-kitchen', Pathname.pwd + config[:build_tempdir])
cmd << " -f #{Shellwords.escape(dockerfile_path(file))}" if config[:build_context]
build_context = config[:build_context] ? '.' : '-'
output = begin
file.write(dockerfile)
file.close