|
|
@ -1432,15 +1432,20 @@ service_base_docker_image() { |
|
|
|
err "Could not get docker-compose service definition for $DARKYELLOW$master_service$NORMAL." |
|
|
|
return 1 |
|
|
|
} |
|
|
|
service_image=$(echo "$service_def" | shyaml get-value image 2>/dev/null) |
|
|
|
if [ "$?" != 0 ]; then |
|
|
|
if service_image=$(echo "$service_def" | shyaml get-value image 2>/dev/null); then |
|
|
|
printf "%s" "${service_image}" | tee "$cache_file" |
|
|
|
return $? |
|
|
|
fi |
|
|
|
|
|
|
|
## According to https://stackoverflow.com/questions/32230577 , if there's a build, |
|
|
|
## then the builded image will get name ${project}_${service} |
|
|
|
## then the built image will get name ${project}_${service} |
|
|
|
project=$(get_default_project_name) || return 1 |
|
|
|
image_name="${project}_${master_service}" |
|
|
|
if ! docker_has_image "$image_name"; then |
|
|
|
service_build=$(echo "$service_def" | shyaml get-value build 2>/dev/null) |
|
|
|
if [ "$?" != 0 ]; then |
|
|
|
if docker_has_image "$image_name"; then |
|
|
|
printf "%s" "${image_name}" | tee "$cache_file" |
|
|
|
return $? |
|
|
|
fi |
|
|
|
if ! service_build=$(echo "$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." |
|
|
|
echo "$service_def" >&2 |
|
|
|
return 1 |
|
|
@ -1450,16 +1455,8 @@ service_base_docker_image() { |
|
|
|
err "Failed to build image '${image_name}' for ${DARKYELLOW}$service${NORMAL}." |
|
|
|
return 1 |
|
|
|
} |
|
|
|
fi |
|
|
|
printf "%s" "${image_name}" |
|
|
|
else |
|
|
|
printf "%s" "${service_image}" |
|
|
|
fi | tee "$cache_file" |
|
|
|
if [ "${PIPESTATUS[0]}" != 0 ]; then |
|
|
|
rm "$cache_file" |
|
|
|
return 1 |
|
|
|
fi |
|
|
|
|
|
|
|
printf "%s" "${image_name}" | tee "$cache_file" |
|
|
|
return $? |
|
|
|
} |
|
|
|
export -f service_base_docker_image |
|
|
|
|
|
|
|