file_diff_docker_import_fn() { s3_path="<%= data[:base_image] %>" log "fetch: starting to fetch $s3_path" aws s3 cp --quiet $s3_path - 2> >(log) log "fetch: successfully fetched $s3_path" } docker_import() { repo=<%= data[:repo] %> tag=<%= data[:tag] %> (cat "<%= data[:diff_image] %>"; file_diff_docker_import_fn) | gunzip -c | docker import - $repo:$tag } worked=1 for attempt in {1..200}; do [[ $worked != 0]] || break docker_import && worked=0 || (log "fetch: attempt $attempt failed, sleeping 30"; sleep 30) done [[ $worked != 0 ]] && fatal "fetch: failed to import diff image" log "fetch: successfully imported image"