|
@ -384,27 +384,36 @@ check_no_links_subdirs() { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## requires docker_run_opts to be set |
|
|
|
|
|
get_compose_file_opt() { |
|
|
|
|
|
local compose_docker_image="$1" hash override |
|
|
|
|
|
shift |
|
|
|
|
|
image_id=$(docker_image_id "$compose_docker_image") |
|
|
|
|
|
override=$(get_volume_opt "${docker_run_opts[@]}") || return 1 |
|
|
|
|
|
|
|
|
get_override() { |
|
|
|
|
|
local override |
|
|
|
|
|
override=$(get_volume_opt "$@") || return 1 |
|
|
if [ -n "$override" ]; then |
|
|
if [ -n "$override" ]; then |
|
|
if ! [ -f "$override" ]; then |
|
|
if ! [ -f "$override" ]; then |
|
|
err "Invalid override of 'compose-core' detected. File '$override' does not exist on host." |
|
|
|
|
|
|
|
|
err "Invalid override of 'compose-core' detected." \ |
|
|
|
|
|
"File '$override' does not exist on host." |
|
|
return 1 |
|
|
return 1 |
|
|
fi |
|
|
fi |
|
|
hash=$( { p0 "$image_id"; cat "$override"; } | md5_compat) |
|
|
|
|
|
else |
|
|
|
|
|
hash=$(p0 "$image_id" | md5_compat) |
|
|
|
|
|
|
|
|
echo "$override" |
|
|
fi |
|
|
fi |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_get_compose_file_opt "$hash" "$override" "$@" || return 1 |
|
|
|
|
|
|
|
|
get_hash_image() { |
|
|
|
|
|
local compose_docker_image="$1" override="$2" |
|
|
|
|
|
{ |
|
|
|
|
|
docker_image_id "$compose_docker_image" || { |
|
|
|
|
|
err "Failed to get docker image id of image '$compose_docker_image'." |
|
|
|
|
|
return 1 |
|
|
|
|
|
} |
|
|
|
|
|
p0 "" |
|
|
|
|
|
[ -n "$override" ] && cat "$override" |
|
|
|
|
|
true |
|
|
|
|
|
} | md5_compat |
|
|
|
|
|
return "${PIPESTATUS[0]}" |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_get_compose_file_opt() { |
|
|
|
|
|
|
|
|
get_compose_file_opt() { |
|
|
local hash_bin="$1" override="$2" \ |
|
|
local hash_bin="$1" override="$2" \ |
|
|
cache_file="$COMPOSE_LAUNCHER_CACHE/$FUNCNAME.cache.$(p0 "$@" | md5_compat)" |
|
|
cache_file="$COMPOSE_LAUNCHER_CACHE/$FUNCNAME.cache.$(p0 "$@" | md5_compat)" |
|
|
if [ -e "$cache_file" ]; then |
|
|
if [ -e "$cache_file" ]; then |
|
@ -444,24 +453,6 @@ _get_compose_file_opt() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
replace_compose_file_opt() { |
|
|
replace_compose_file_opt() { |
|
|
local compose_docker_image="$1" hash override |
|
|
|
|
|
shift |
|
|
|
|
|
image_id=$(docker_image_id "$compose_docker_image") |
|
|
|
|
|
override=$(get_volume_opt "${docker_run_opts[@]}") || return 1 |
|
|
|
|
|
if [ -n "$override" ]; then |
|
|
|
|
|
if ! [ -f "$override" ]; then |
|
|
|
|
|
err "Invalid override of 'compose-core' detected. File '$override' does not exist on host." |
|
|
|
|
|
return 1 |
|
|
|
|
|
fi |
|
|
|
|
|
hash=$( { p0 "$image_id"; cat "$override"; } | md5_compat) |
|
|
|
|
|
else |
|
|
|
|
|
hash=$(p0 "$image_id" | md5_compat) |
|
|
|
|
|
fi |
|
|
|
|
|
_replace_compose_file_opt "$hash" "$override" "$@" || return 1 |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_replace_compose_file_opt() { |
|
|
|
|
|
local hash_bin="$1" override="$2" \ |
|
|
local hash_bin="$1" override="$2" \ |
|
|
cache_file="$COMPOSE_LAUNCHER_CACHE/$FUNCNAME.cache.$(p0 "$@" | md5_compat)" |
|
|
cache_file="$COMPOSE_LAUNCHER_CACHE/$FUNCNAME.cache.$(p0 "$@" | md5_compat)" |
|
|
if [ -e "$cache_file" ]; then |
|
|
if [ -e "$cache_file" ]; then |
|
@ -856,6 +847,9 @@ mk_docker_run_options() { |
|
|
|
|
|
|
|
|
COMPOSE_LAUNCHER_BIN=$(readlink -f "${BASH_SOURCE[0]}") |
|
|
COMPOSE_LAUNCHER_BIN=$(readlink -f "${BASH_SOURCE[0]}") |
|
|
docker_run_opts+=("-v" "$COMPOSE_LAUNCHER_BIN:/usr/local/bin/compose") |
|
|
docker_run_opts+=("-v" "$COMPOSE_LAUNCHER_BIN:/usr/local/bin/compose") |
|
|
|
|
|
COMPOSE_LAUNCHER_BIN_OVERRIDE=$(get_override "${docker_run_opts[@]}") || return 1 |
|
|
|
|
|
COMPOSE_LAUNCHER_HASH=$( |
|
|
|
|
|
get_hash_image "$COMPOSE_DOCKER_IMAGE" "$COMPOSE_LAUNCHER_BIN_OVERRIDE") || return 1 |
|
|
|
|
|
|
|
|
while read-0 var; do |
|
|
while read-0 var; do |
|
|
case "$var" in |
|
|
case "$var" in |
|
@ -869,7 +863,9 @@ mk_docker_run_options() { |
|
|
esac |
|
|
esac |
|
|
done < <(list_compose_vars) |
|
|
done < <(list_compose_vars) |
|
|
|
|
|
|
|
|
ARG_COMPOSE_FILE=$(get_compose_file_opt "$COMPOSE_DOCKER_IMAGE" "$@") || return 1 |
|
|
|
|
|
|
|
|
ARG_COMPOSE_FILE=$( |
|
|
|
|
|
get_compose_file_opt "$COMPOSE_LAUNCHER_HASH" "$COMPOSE_LAUNCHER_BIN_OVERRIDE" \ |
|
|
|
|
|
"$@") || return 1 |
|
|
|
|
|
|
|
|
if [ -z "$ARG_COMPOSE_FILE" ]; then |
|
|
if [ -z "$ARG_COMPOSE_FILE" ]; then |
|
|
## Find a compose.yml in parents |
|
|
## Find a compose.yml in parents |
|
@ -928,7 +924,7 @@ mk_docker_run_options() { |
|
|
docker_run_opts+=("${additional_docker_run_opts[@]}") |
|
|
docker_run_opts+=("${additional_docker_run_opts[@]}") |
|
|
|
|
|
|
|
|
## keep also some env vars: |
|
|
## keep also some env vars: |
|
|
for var in ARG_COMPOSE_FILE COMPOSE_DOCKER_IMAGE; do |
|
|
|
|
|
|
|
|
for var in ARG_COMPOSE_FILE COMPOSE_DOCKER_IMAGE COMPOSE_LAUNCHER_{BIN_OVERRIDE,HASH}; do |
|
|
p0 "!env:$var=${!var}" |
|
|
p0 "!env:$var=${!var}" |
|
|
done >> "$filename" |
|
|
done >> "$filename" |
|
|
|
|
|
|
|
@ -973,7 +969,10 @@ run() { |
|
|
set_os |
|
|
set_os |
|
|
|
|
|
|
|
|
if [ -n "$ARG_COMPOSE_FILE" ]; then |
|
|
if [ -n "$ARG_COMPOSE_FILE" ]; then |
|
|
array_read-0 cmd_args < <(replace_compose_file_opt "$COMPOSE_DOCKER_IMAGE" "$@") |
|
|
|
|
|
|
|
|
array_read-0 cmd_args < \ |
|
|
|
|
|
<(replace_compose_file_opt "$COMPOSE_LAUNCHER_HASH" \ |
|
|
|
|
|
"$COMPOSE_LAUNCHER_BIN_OVERRIDE" \ |
|
|
|
|
|
"$@") |
|
|
set -- "${cmd_args[@]}" |
|
|
set -- "${cmd_args[@]}" |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|