Sha256: 569a77d4d10069d6ef645da863b39c4d228f0514b58bb9dbed74d4ff492244a3

Contents?: true

Size: 1.56 KB

Versions: 5

Compression:

Stored size: 1.56 KB

Contents

<%
base_image = "/opt/dockly/base_image.tar"
%>

s3_diff_docker_import_base_fn() {
  s3_path="<%= data[:base_image] %>"
  log "fetch: starting to fetch $s3_path"
  # TODO: Remove timeout once https://github.com/aws/aws-cli/issues/1178 closes
  timeout 600 aws s3 cp --quiet $s3_path - 2> >(log)
  log "fetch: successfully fetched $s3_path"
}

s3_diff_docker_import_diff_fn() {
  s3_path="<%= data[:diff_image] %>"
  log "fetch: starting to fetch $s3_path"
  timeout 600 aws s3 cp --quiet $s3_path - 2> >(log)
  log "fetch: successfully fetched $s3_path"
}

base_image() {
  s3_diff_docker_import_base_fn | gunzip -vc > "<%= base_image %>" 2> >(log)
}

stream_image() {
  size=$(stat --format "%s" "<%= base_image %>")
  head_size=$(($size - 1024))
  head -c $head_size "<%= base_image %>"
  s3_diff_docker_import_diff_fn | (gunzip -vc 2> >(log) || fatal "tardiff failed to gunzip")
}

docker_import() {
  repo=<%= data[:repo] %>
  tag=<%= data[:tag] %>
  docker import - $repo:$tag > >(log) 2>&1 || fatal "docker failed to import"
}

worked=1
for attempt in {1..200}; do
  [[ $worked != 0 ]] || break
  base_image && worked=0 || (log "fetch: attempt $attempt failed, sleeping 30"; sleep 30)
done
[[ $worked != 0 ]] && fatal "fetch: failed to pull base image"
log "fetch: successfully pulled base image"

worked=1
for attempt in {1..200}; do
  [[ $worked != 0 ]] || break
  stream_image | 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 diff image"

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
dockly-2.4.0 snippets/s3_diff_docker_import.erb
dockly-2.3.0 snippets/s3_diff_docker_import.erb
dockly-2.2.0 snippets/s3_diff_docker_import.erb
dockly-2.1.0 snippets/s3_diff_docker_import.erb
dockly-2.0.2 snippets/s3_diff_docker_import.erb