Skip to content
This repository has been archived by the owner on Feb 2, 2022. It is now read-only.

Set variable CHE_DOCKER_MACHINE_HOST_EXTERNAL on Docker for Mac and Windows #11

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions che-launcher/launcher.sh
Expand Up @@ -63,6 +63,7 @@ init_global_variables() {
DEFAULT_CHE_DEBUG_SERVER="false"
DEFAULT_CHE_DEBUG_SERVER_PORT="8000"
DEFAULT_CHE_DEBUG_SERVER_SUSPEND="false"
DEFAULT_CHE_DOCKER_MACHINE_HOST_EXTERNAL=$(get_docker_external_hostname)

# Clean eventual user provided paths
CHE_CONF_FOLDER=${CHE_CONF_FOLDER:+$(get_converted_and_clean_path "${CHE_CONF_FOLDER}")}
Expand All @@ -84,6 +85,7 @@ init_global_variables() {
CHE_DEBUG_SERVER=${CHE_DEBUG_SERVER:-${DEFAULT_CHE_DEBUG_SERVER}}
CHE_DEBUG_SERVER_PORT=${CHE_DEBUG_SERVER_PORT:-${DEFAULT_CHE_DEBUG_SERVER_PORT}}
CHE_DEBUG_SERVER_SUSPEND=${CHE_DEBUG_SERVER_SUSPEND:-${DEFAULT_CHE_DEBUG_SERVER_SUSPEND}}
CHE_DOCKER_MACHINE_HOST_EXTERNAL=${CHE_DOCKER_MACHINE_HOST_EXTERNAL:-${DEFAULT_CHE_DOCKER_MACHINE_HOST_EXTERNAL}}

CHE_CONF_LOCATION="${CHE_CONF_FOLDER}":"/conf"
CHE_STORAGE_LOCATION="${CHE_DATA_FOLDER}/storage":"/home/user/che/storage"
Expand Down
1 change: 1 addition & 0 deletions che-launcher/launcher_cmds.sh
Expand Up @@ -100,6 +100,7 @@ print_debug_info() {
debug "DOCKER_INSTALL_TYPE = ${DOCKER_INSTALL_TYPE}"
debug "DOCKER_HOST_OS = $(get_docker_host_os)"
debug "DOCKER_HOST_IP = ${DEFAULT_DOCKER_HOST_IP}"
debug "DOCKER_HOST_EXTERNAL_IP = ${DEFAULT_CHE_DOCKER_MACHINE_HOST_EXTERNAL:-not set}"
debug "DOCKER_DAEMON_VERSION = $(get_docker_daemon_version)"
debug ""
debug ""
Expand Down
30 changes: 27 additions & 3 deletions che-launcher/launcher_funcs.sh
Expand Up @@ -144,13 +144,21 @@ docker_run_with_conf() {
fi
}

docker_run_with_external_hostname() {
if has_external_hostname; then
docker_run_with_conf -e "CHE_DOCKER_MACHINE_HOST_EXTERNAL=${CHE_DOCKER_MACHINE_HOST_EXTERNAL}" "$@"
else
docker_run_with_conf "$@"
fi
}

docker_run_with_debug() {
if has_debug && has_debug_suspend; then
docker_run_with_conf -p "${CHE_DEBUG_SERVER_PORT}":8000 -e "JPDA_SUSPEND=y" "$@"
docker_run_with_external_hostname -p "${CHE_DEBUG_SERVER_PORT}":8000 -e "JPDA_SUSPEND=y" "$@"
elif has_debug; then
docker_run_with_conf -p "${CHE_DEBUG_SERVER_PORT}":8000 "$@"
docker_run_with_external_hostname -p "${CHE_DEBUG_SERVER_PORT}":8000 "$@"
else
docker_run_with_conf "$@"
docker_run_with_external_hostname "$@"
fi
}

Expand Down Expand Up @@ -186,6 +194,14 @@ has_local_binary_path() {
fi
}

has_external_hostname() {
if [ "${CHE_DOCKER_MACHINE_HOST_EXTERNAL}" = "" ]; then
return 1
else
return 0
fi
}

get_list_of_che_system_environment_variables() {
# See: http://stackoverflow.com/questions/4128235/what-is-the-exact-meaning-of-ifs-n
IFS=$'\n'
Expand Down Expand Up @@ -328,6 +344,14 @@ get_che_server_container_id() {
docker ps -q -a -f "name=${CHE_SERVER_CONTAINER_NAME}"
}

get_docker_external_hostname() {
if is_docker_for_mac || is_docker_for_windows; then
echo "localhost"
else
echo ""
fi
}

wait_until_container_is_running() {
CONTAINER_START_TIMEOUT=${1}

Expand Down