Browse Source

new: [compose-core] move partial docker-compose to a file

master
Valentin Lab 8 months ago
parent
commit
838323f18e
  1. 24
      bin/compose-core

24
bin/compose-core

@ -1287,8 +1287,8 @@ get_docker_compose () {
merge_yaml_str "$(yaml_key_val_str "services" "$docker_compose_services")" \
"$base_v2" > "$cache_file" || return 1
export _current_docker_compose="$(cat "$cache_file")"
echo "$_current_docker_compose"
export _CURRENT_DOCKER_COMPOSE="$cache_file"
cat "$_CURRENT_DOCKER_COMPOSE"
debug " ..compilation of base 'docker-compose.yml' done $GRAY(in $((SECONDS - start_compilation))s)$NORMAL" || true
# debug " ** ${WHITE}docker-compose.yml${NORMAL}:"
# debug "$_current_docker_compose"
@ -1392,12 +1392,15 @@ export -f get_service_charm
## full docker-compose.yml to be already built.
get_service_def () {
local service="$1" def
if [ -z "$_current_docker_compose" ]; then
print_syntax_error "$FUNCNAME is meant to be called after"\
"\$_current_docker_compose has been calculated."
if [ -z "$_CURRENT_DOCKER_COMPOSE" ]; then
err "${FUNCNAME[0]} is meant to be called after"\
"\$_CURRENT_DOCKER_COMPOSE has been calculated."
echo " Called by:" >&2
printf " - %s\n" "${FUNCNAME[@]:1}" >&2
return 1
fi
def=$(echo "$_current_docker_compose" | shyaml get-value "services.${service//./\\.}" 2>/dev/null)
def=$(cat "$_CURRENT_DOCKER_COMPOSE" | shyaml get-value "services.${service//./\\.}" 2>/dev/null)
if [ -z "$def" ]; then
err "No definition for service $DARKYELLOW$service$NORMAL in compiled 'docker-compose.yml'."
return 1
@ -3847,7 +3850,14 @@ launch_docker_compose() {
mkdir -p "$docker_compose_tmpdir/$project"
docker_compose_dir="$docker_compose_tmpdir/$project"
get_docker_compose $SERVICE_PACK > "$docker_compose_dir/docker-compose.yml" || return 1
if [ -z "$_CURRENT_DOCKER_COMPOSE" ]; then
err "${FUNCNAME[0]} is meant to be called after"\
"\$_CURRENT_DOCKER_COMPOSE has been calculated."
echo " Called by:" >&2
printf " - %s\n" "${FUNCNAME[@]:1}" >&2
return 1
fi
cat "$_CURRENT_DOCKER_COMPOSE" > "$docker_compose_dir/docker-compose.yml" || return 1
if [ -e "$state_tmpdir/to-merge-in-docker-compose.yml" ]; then
# debug "Merging some config data in docker-compose.yml:"
# debug "$(cat $state_tmpdir/to-merge-in-docker-compose.yml)"

Loading…
Cancel
Save