From 4904a30cb1689b8e0004d93f0c53576b569bd8dd Mon Sep 17 00:00:00 2001 From: Michael Priest Date: Mon, 16 Apr 2018 17:09:29 +0930 Subject: [PATCH] =?UTF-8?q?Determine=20the=20nginx=20port=20at=20run=20tim?= =?UTF-8?q?e=20to=20generate=20a=20working=20link=20under=E2=80=A6=20(#28)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Determine the nginx port at run time to generate a working link under non-port-80 conditions. * Remove debug code. Sigh. --- dsh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/dsh b/dsh index 9b18c29..293a3bf 100755 --- a/dsh +++ b/dsh @@ -12,8 +12,11 @@ MACHINE='default' # exists in global DNS, which may cause issues reassigning it with dnsmasq. export DOMAIN=${DOMAIN:-'test'} +# Nginx proxy exposed port. Useful when using something other than 80. +export NGINX_PORT=$(docker port nginx-proxy | awk -F ':' '{print $2}') + # Used as the prefix for docker networking, container naming and nginx hostname. -export PROJECT=$(basename ${PWD} | sed 's/[-_]//g') +export PROJECT=$(basename ${PWD}) # Determine the OS type of the host machine. if [ "$(uname)" == "Darwin" ]; then @@ -53,8 +56,9 @@ dsh_start() { notice "Starting project containers." docker-compose up -d setup_xdebug + export URL="http://${PROJECT}.${DOMAIN}$(if [ ! $NGINX_PORT -eq '80' ]; then echo ":$NGINX_PORT"; fi)" notice "Please wait about 10 seconds for the database to settle. -You can now access the site from http://${PROJECT}.${DOMAIN}. +You can now access the site from ${URL}. Project files are available in /code, You may need to build and install your project before it starts working. Connecting via ./dsh shell and running robo build is a common next step." @@ -242,6 +246,9 @@ setup_nginx_proxy() { if ! docker ps | grep "nginx-proxy" > /dev/null; then error "jwilder/nginx-proxy could not be started." + else + # Update the nginx port as it wasn't running initially. + export NGINX_PORT=$(docker port nginx-proxy | awk -F ':' '{print $2}') fi }