@@ -49,28 +49,43 @@ DEP_BUILD_ORDER = [
4949 'trapperkeeper-comidi-metrics' ,
5050] . freeze
5151
52+ # somewhat annoyingly, with --format=json there are differences between
53+ # podman and docker. Docker will output one JSON record per line, but podman
54+ # will put everything into an array. Do something simple that can handle both.
55+ def non_empty ( output )
56+ if output . strip . empty?
57+ return true
58+ end
59+
60+ begin
61+ return !JSON . parse ( output ) . empty?
62+ rescue JSON ::ParseError => e
63+ return false
64+ end
65+ end
66+
5267def image_exists
53- ! ` docker images -q #{ @image } ` . strip . empty?
68+ non_empty ( `${DOCKER- docker} images -q #{ @image } --format=json` )
5469end
5570
5671def container_exists
57- ! ` docker container ls --all --filter 'name=#{ @container } ' --format json`. strip . empty?
72+ non_empty ( `${DOCKER- docker} container ls --all --filter 'name=#{ @container } ' --format= json`)
5873end
5974
6075def teardown
6176 if container_exists
6277 puts "Stopping #{ @container } "
63- run_command ( "docker stop #{ @container } " , silent : false , print_command : true )
64- run_command ( "docker rm #{ @container } " , silent : false , print_command : true )
78+ run_command ( "${DOCKER- docker} stop #{ @container } " , silent : false , print_command : true )
79+ run_command ( "${DOCKER- docker} rm #{ @container } " , silent : false , print_command : true )
6580 end
6681end
6782
6883def start_container ( ezbake_dir )
69- run_command ( "docker run -d --name #{ @container } -v .:/code -v #{ ezbake_dir } :/deps #{ @image } /bin/sh -c 'tail -f /dev/null'" , silent : false , print_command : true )
84+ run_command ( "${DOCKER- docker} run -d --name #{ @container } -v .:/code -v #{ ezbake_dir } :/deps #{ @image } /bin/sh -c 'tail -f /dev/null'" , silent : false , print_command : true )
7085end
7186
7287def run ( cmd )
73- run_command ( "docker exec #{ @container } /bin/bash --login -c '#{ cmd } '" , silent : false , print_command : true )
88+ run_command ( "${DOCKER- docker} exec #{ @container } /bin/bash --login -c '#{ cmd } '" , silent : false , print_command : true )
7489end
7590
7691namespace :vox do
@@ -89,7 +104,7 @@ namespace :vox do
89104 # delete all containers and do `docker rmi ezbake-builder`
90105 unless image_exists
91106 puts "Building ezbake-builder image"
92- run_command ( "docker build -t ezbake-builder ." , silent : false , print_command : true )
107+ run_command ( "${DOCKER- docker} build -t ezbake-builder ." , silent : false , print_command : true )
93108 end
94109
95110 libs_to_build_manually = { }
0 commit comments