snippets/s3_docker_import.erb in dockly-1.6.0 vs snippets/s3_docker_import.erb in dockly-1.7.0

- old
+ new

@@ -1,4 +1,20 @@ s3_docker_import_fn() { -<%= get_from_s3(data[:s3_url]) %> + s3_path="<%= data[:s3_url] %>" + log "fetch: starting to fetch $s3_path" + s3cmd -f get $s3_path - 2> >(log) + log "fetch: successfully fetched $s3_path" } -s3_docker_import_fn | gunzip -c | <%= docker_import(data[:repo], data[:tag]) %> + +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"