Browse Source

fix: in WSL, make compose file accessible

We need to copy compose file in a docker host accessible
directory.

Signed-off-by: Valentin Lab <valentin.lab@kalysto.org>
lokavaluto/dev/master
Valentin Lab 5 years ago
parent
commit
fc3a1ff17e
  1. 40
      bin/compose

40
bin/compose

@ -826,26 +826,6 @@ mk_docker_run_options() {
)
check_no_links_subdirs "$CHARM_STORE"/* || return 1
## DEFAULT_COMPOSE_FILE
if [ "${DEFAULT_COMPOSE_FILE+x}" ]; then
DEFAULT_COMPOSE_FILE=$(realpath "$DEFAULT_COMPOSE_FILE")
dirname=$(dirname "$DEFAULT_COMPOSE_FILE")/
if [ -e "${DEFAULT_COMPOSE_FILE}" ]; then
docker_run_opts+=("-v" "$dirname:$dirname:ro")
fi
fi
## COMPOSE_YML_FILE
if [ "${COMPOSE_YML_FILE+x}" ]; then
if [ -e "${COMPOSE_YML_FILE}" ]; then
docker_run_opts+=(
"-v" "$COMPOSE_YML_FILE:/tmp/compose.yml:ro"
"-e" "COMPOSE_YML_FILE=/tmp/compose.yml"
"-e" "HOST_COMPOSE_YML_FILE=/tmp/compose.yml"
)
fi
fi
## DATASTORE and CONFIGSTORE
docker_run_opts+=(
@ -897,7 +877,9 @@ mk_docker_run_options() {
get_compose_file_opt "$COMPOSE_LAUNCHER_HASH" "$COMPOSE_LAUNCHER_BIN_OVERRIDE" \
"$@") || return 1
if [ -z "$ARG_COMPOSE_FILE" ]; then
compose_file="${ARG_COMPOSE_FILE:-$COMPOSE_YML_FILE}"
if [ -z "$compose_file" ]; then
## Find a compose.yml in parents
debug "No config file specified on command line arguments"
debug "Looking for 'compose.yml' in self and parents.."
@ -915,8 +897,6 @@ mk_docker_run_options() {
else
debug " .. not found."
fi
else
compose_file="$ARG_COMPOSE_FILE"
fi
if [ -n "$compose_file" ]; then
@ -924,11 +904,23 @@ mk_docker_run_options() {
die "Specified compose file '$compose_file' not found."
fi
compose_file="$(realpath "$compose_file")"
if [ "$OS" == "wsl" ]; then
## Docker host is not same linux than WSL, so
## access to root files are not the same.
##YYYvlab, check on cp where is the base
dst="$COMPOSE_LAUNCHER_CACHE/compose.$(md5_compat < "$compose_file").yml"
cp "$compose_file" "$dst"
## docker host start with /c/... whereas WSL could start with /mnt/c/...
local="$dst"
else
local="$compose_file"
fi
parent_dir="${compose_file%/*}"
docker_path=/var/lib/compose/root/${parent_dir##*/}/${compose_file##*/}
docker_run_opts+=(
"-e" "COMPOSE_YML_FILE=${compose_file##*/}"
"-v" "${compose_file}:${docker_path}:ro"
"-v" "${local}:${docker_path}:ro"
"-w" "${docker_path%/*}"
)
else

Loading…
Cancel
Save