|
@ -869,9 +869,9 @@ mk_docker_run_options() { |
|
|
esac |
|
|
esac |
|
|
done < <(list_compose_vars) |
|
|
done < <(list_compose_vars) |
|
|
|
|
|
|
|
|
compose_file=$(get_compose_file_opt "$COMPOSE_DOCKER_IMAGE" "$@") || return 1 |
|
|
|
|
|
|
|
|
ARG_COMPOSE_FILE=$(get_compose_file_opt "$COMPOSE_DOCKER_IMAGE" "$@") || return 1 |
|
|
|
|
|
|
|
|
if [ -z "$compose_file" ]; then |
|
|
|
|
|
|
|
|
if [ -z "$ARG_COMPOSE_FILE" ]; then |
|
|
## Find a compose.yml in parents |
|
|
## Find a compose.yml in parents |
|
|
debug "No config file specified on command line arguments" |
|
|
debug "No config file specified on command line arguments" |
|
|
debug "Looking for 'compose.yml' in self and parents.." |
|
|
debug "Looking for 'compose.yml' in self and parents.." |
|
@ -889,6 +889,8 @@ mk_docker_run_options() { |
|
|
else |
|
|
else |
|
|
debug " .. not found." |
|
|
debug " .. not found." |
|
|
fi |
|
|
fi |
|
|
|
|
|
else |
|
|
|
|
|
compose_file="$ARG_COMPOSE_FILE" |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
if [ -n "$compose_file" ]; then |
|
|
if [ -n "$compose_file" ]; then |
|
@ -917,15 +919,21 @@ mk_docker_run_options() { |
|
|
sha=${sha:0:64} |
|
|
sha=${sha:0:64} |
|
|
src="$SESSION_DIR/$UID-$sha" |
|
|
src="$SESSION_DIR/$UID-$sha" |
|
|
dest="/var/lib/compose/sessions/$UID-$sha" |
|
|
dest="/var/lib/compose/sessions/$UID-$sha" |
|
|
{ |
|
|
|
|
|
p0 "-v" "$SESSION_DIR/$UID-$sha:$dest:ro" |
|
|
|
|
|
p0 "-e" "COMPOSE_LAUNCHER_OPTS=$dest" |
|
|
|
|
|
p0 "-e" "COMPOSE_LAUNCHER_BIN=$COMPOSE_LAUNCHER_BIN" |
|
|
|
|
|
} >> "$filename" |
|
|
|
|
|
|
|
|
additional_docker_run_opts=( |
|
|
|
|
|
"-v" "$SESSION_DIR/$UID-$sha:$dest:ro" |
|
|
|
|
|
"-e" "COMPOSE_LAUNCHER_OPTS=$dest" |
|
|
|
|
|
"-e" "COMPOSE_LAUNCHER_BIN=$COMPOSE_LAUNCHER_BIN" |
|
|
|
|
|
) |
|
|
|
|
|
p0 "${additional_docker_run_opts[@]}" >> "$filename" |
|
|
|
|
|
docker_run_opts+=("${additional_docker_run_opts[@]}") |
|
|
|
|
|
|
|
|
|
|
|
## keep also some env vars: |
|
|
|
|
|
for var in ARG_COMPOSE_FILE COMPOSE_DOCKER_IMAGE; do |
|
|
|
|
|
p0 "!env:$var=${!var}" |
|
|
|
|
|
done >> "$filename" |
|
|
|
|
|
|
|
|
mkdir -p "$SESSION_DIR" || return 1 |
|
|
mkdir -p "$SESSION_DIR" || return 1 |
|
|
mv -f "$filename" "$SESSION_DIR/$UID-$sha" || return 1 |
|
|
|
|
|
e "$SESSION_DIR/$UID-$sha" |
|
|
|
|
|
|
|
|
mv -f "$filename" "$src" || return 1 |
|
|
|
|
|
|
|
|
if [ -n "$DEBUG" ]; then |
|
|
if [ -n "$DEBUG" ]; then |
|
|
echo "${WHITE}Environment:${NORMAL}" |
|
|
echo "${WHITE}Environment:${NORMAL}" |
|
@ -947,25 +955,27 @@ run() { |
|
|
|
|
|
|
|
|
docker_run_opts=() |
|
|
docker_run_opts=() |
|
|
if [ -z "$COMPOSE_LAUNCHER_OPTS" ]; then |
|
|
if [ -z "$COMPOSE_LAUNCHER_OPTS" ]; then |
|
|
COMPOSE_LAUNCHER_OPTS="$(mk_docker_run_options "$@")" || return 1 |
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mk_docker_run_options "$@" || return 1 |
|
|
|
|
|
else |
|
|
while read-0 opt; do |
|
|
while read-0 opt; do |
|
|
docker_run_opts+=("$opt") |
|
|
|
|
|
## catch COMPOSE_DOCKER_IMAGE |
|
|
|
|
|
if [[ "$env" == "true" && "$opt" == "COMPOSE_DOCKER_IMAGE="* ]]; then |
|
|
|
|
|
COMPOSE_DOCKER_IMAGE=${opt##COMPOSE_DOCKER_IMAGE=} |
|
|
|
|
|
elif [ "$opt" == "-e" ]; then |
|
|
|
|
|
env=true |
|
|
|
|
|
|
|
|
if [[ "$opt" == "!env:"* ]]; then |
|
|
|
|
|
opt="${opt##!env:}" |
|
|
|
|
|
var="${opt%%=*}" |
|
|
|
|
|
value="${opt#*=}" |
|
|
|
|
|
debug "Loading var: $var=$value" |
|
|
|
|
|
export "$var"="$value" |
|
|
else |
|
|
else |
|
|
env= |
|
|
|
|
|
|
|
|
docker_run_opts+=("$opt") |
|
|
fi |
|
|
fi |
|
|
done < <(cat "$COMPOSE_LAUNCHER_OPTS") |
|
|
done < <(cat "$COMPOSE_LAUNCHER_OPTS") |
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
set_os |
|
|
set_os |
|
|
|
|
|
|
|
|
|
|
|
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_DOCKER_IMAGE" "$@") |
|
|
set -- "${cmd_args[@]}" |
|
|
set -- "${cmd_args[@]}" |
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
[ -t 0 ] && docker_run_opts+=("-i") |
|
|
[ -t 0 ] && docker_run_opts+=("-i") |
|
|
[ -t 1 ] && docker_run_opts+=("-t") |
|
|
[ -t 1 ] && docker_run_opts+=("-t") |
|
|