s3_docker_import_fn() { s3_path="<%= data[:s3_url] %>" 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] %> s3_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 "failed to import image" log "fetch: successfully imported image"