|
@ -1773,7 +1773,8 @@ service_ensure_image_ready() { |
|
|
err "Expected \$COMBINED_HASH to be set." |
|
|
err "Expected \$COMBINED_HASH to be set." |
|
|
return 1 |
|
|
return 1 |
|
|
fi |
|
|
fi |
|
|
local service="$1" cache_file="$CACHEDIR/$FUNCNAME.cache.$1.$COMBINED_HASH" \ |
|
|
|
|
|
|
|
|
local service="$1" \ |
|
|
|
|
|
cache_file="$CACHEDIR/$FUNCNAME.cache.$1.$(H "$COMBINED_HASH" "$(cat "$_CURRENT_DOCKER_COMPOSE")")" \ |
|
|
master_service service_def service_image service_build service_dockerfile image \ |
|
|
master_service service_def service_image service_build service_dockerfile image \ |
|
|
specified_image specified_image_id charm_image_name hash \ |
|
|
specified_image specified_image_id charm_image_name hash \ |
|
|
service_quoted |
|
|
service_quoted |
|
@ -1781,6 +1782,7 @@ service_ensure_image_ready() { |
|
|
if [ -e "$cache_file" ]; then |
|
|
if [ -e "$cache_file" ]; then |
|
|
#debug "$FUNCNAME: cache hit ($*)" |
|
|
#debug "$FUNCNAME: cache hit ($*)" |
|
|
touch "$cache_file" || return 1 |
|
|
touch "$cache_file" || return 1 |
|
|
|
|
|
cp "$cache_file.cdc" "$_CURRENT_DOCKER_COMPOSE" || return 1 |
|
|
cat "$cache_file" |
|
|
cat "$cache_file" |
|
|
return 0 |
|
|
return 0 |
|
|
fi |
|
|
fi |
|
@ -1798,8 +1800,9 @@ service_ensure_image_ready() { |
|
|
} |
|
|
} |
|
|
if [ "$master_service" != "$service" ]; then |
|
|
if [ "$master_service" != "$service" ]; then |
|
|
image=$(service_ensure_image_ready "$master_service") || return 1 |
|
|
image=$(service_ensure_image_ready "$master_service") || return 1 |
|
|
printf "%s" "$image" | tee "$cache_file" |
|
|
|
|
|
return $? |
|
|
|
|
|
|
|
|
printf "%s" "$image" | tee "$cache_file" || return 1 |
|
|
|
|
|
cp "$_CURRENT_DOCKER_COMPOSE" "$cache_file.cdc" || return 1 |
|
|
|
|
|
return 0 |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
## check if \$_CURRENT_DOCKER_COMPOSE's service def is already correctly setup |
|
|
## check if \$_CURRENT_DOCKER_COMPOSE's service def is already correctly setup |
|
@ -1813,7 +1816,8 @@ service_ensure_image_ready() { |
|
|
if specified_image=$(e "$service_def" | shyaml get-value image 2>/dev/null); then |
|
|
if specified_image=$(e "$service_def" | shyaml get-value image 2>/dev/null); then |
|
|
if [[ "$specified_image" == "$charm_image_name:"* ]]; then |
|
|
if [[ "$specified_image" == "$charm_image_name:"* ]]; then |
|
|
## Assume we already did the change |
|
|
## Assume we already did the change |
|
|
printf "%s" "$specified_image" | tee "$cache_file" |
|
|
|
|
|
|
|
|
printf "%s" "$specified_image" | tee "$cache_file" || return 1 |
|
|
|
|
|
cp "$_CURRENT_DOCKER_COMPOSE" "$cache_file.cdc" || return 1 |
|
|
return 0 |
|
|
return 0 |
|
|
fi |
|
|
fi |
|
|
if [[ "$specified_image" == "${COMPOSE_DOCKER_REGISTRY}/"* ]]; then |
|
|
if [[ "$specified_image" == "${COMPOSE_DOCKER_REGISTRY}/"* ]]; then |
|
@ -1829,7 +1833,8 @@ service_ensure_image_ready() { |
|
|
fi |
|
|
fi |
|
|
fi |
|
|
fi |
|
|
## Already on the cache server |
|
|
## Already on the cache server |
|
|
printf "%s" "$specified_image" | tee "$cache_file" |
|
|
|
|
|
|
|
|
printf "%s" "$specified_image" | tee "$cache_file" || return 1 |
|
|
|
|
|
cp "$_CURRENT_DOCKER_COMPOSE" "$cache_file.cdc" || return 1 |
|
|
return 0 |
|
|
return 0 |
|
|
fi |
|
|
fi |
|
|
src="$specified_image" |
|
|
src="$specified_image" |
|
@ -1841,7 +1846,7 @@ service_ensure_image_ready() { |
|
|
"$_CURRENT_DOCKER_COMPOSE" || return 1 |
|
|
"$_CURRENT_DOCKER_COMPOSE" || return 1 |
|
|
else |
|
|
else |
|
|
|
|
|
|
|
|
if ! src=$(echo "$service_def" | shyaml get-value build 2>/dev/null); then |
|
|
|
|
|
|
|
|
if ! src=$(e "$service_def" | shyaml get-value build 2>/dev/null); then |
|
|
err "Service $DARKYELLOW$service$NORMAL has no ${WHITE}image${NORMAL} nor ${WHITE}build${NORMAL} parameter." |
|
|
err "Service $DARKYELLOW$service$NORMAL has no ${WHITE}image${NORMAL} nor ${WHITE}build${NORMAL} parameter." |
|
|
echo "$service_def" >&2 |
|
|
echo "$service_def" >&2 |
|
|
return 1 |
|
|
return 1 |
|
@ -1864,22 +1869,25 @@ service_ensure_image_ready() { |
|
|
Feed >&2 |
|
|
Feed >&2 |
|
|
fi |
|
|
fi |
|
|
cache:image:registry:put "$charm" "$hash" "$service" || return 1 |
|
|
cache:image:registry:put "$charm" "$hash" "$service" || return 1 |
|
|
printf "%s" "${charm_image_name}:${hash}" | tee "$cache_file" |
|
|
|
|
|
return $? |
|
|
|
|
|
|
|
|
printf "%s" "${charm_image_name}:${hash}" | tee "$cache_file" || return 1 |
|
|
|
|
|
cp "$_CURRENT_DOCKER_COMPOSE" "$cache_file.cdc" || return 1 |
|
|
|
|
|
return 0 |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
## Can we pull it ? Let's check on $COMPOSE_DOCKER_REGISTRY |
|
|
## Can we pull it ? Let's check on $COMPOSE_DOCKER_REGISTRY |
|
|
if [ "$COMPOSE_ACTION" != "build" ] && [ -n "$COMPOSE_DOCKER_REGISTRY" ]; then |
|
|
if [ "$COMPOSE_ACTION" != "build" ] && [ -n "$COMPOSE_DOCKER_REGISTRY" ]; then |
|
|
img=$(cache:image:registry:get "$charm" "$hash" "$service" 2>/dev/null) |
|
|
img=$(cache:image:registry:get "$charm" "$hash" "$service" 2>/dev/null) |
|
|
[ -n "$img" ] && { |
|
|
[ -n "$img" ] && { |
|
|
printf "%s" "$img" | tee "$cache_file" |
|
|
|
|
|
return $? |
|
|
|
|
|
|
|
|
printf "%s" "$img" | tee "$cache_file" || return 1 |
|
|
|
|
|
cp "$_CURRENT_DOCKER_COMPOSE" "$cache_file.cdc" || return 1 |
|
|
|
|
|
return 0 |
|
|
} |
|
|
} |
|
|
fi |
|
|
fi |
|
|
cache:image:produce "$type" "$src" "$charm" "$hash" "$service" || return 1 |
|
|
cache:image:produce "$type" "$src" "$charm" "$hash" "$service" || return 1 |
|
|
cache:image:registry:put "$charm" "$hash" "$service" || return 1 |
|
|
cache:image:registry:put "$charm" "$hash" "$service" || return 1 |
|
|
printf "%s" "${charm_image_name}:$hash" | tee "$cache_file" |
|
|
|
|
|
return $? |
|
|
|
|
|
|
|
|
printf "%s" "${charm_image_name}:$hash" | tee "$cache_file" || return 1 |
|
|
|
|
|
cp "$_CURRENT_DOCKER_COMPOSE" "$cache_file.cdc" || return 1 |
|
|
|
|
|
return 0 |
|
|
} |
|
|
} |
|
|
export -f service_ensure_image_ready |
|
|
export -f service_ensure_image_ready |
|
|
|
|
|
|
|
|