Skip to content

Commit

Permalink
Determine the nginx port at run time to generate a working link under… (
Browse files Browse the repository at this point in the history
#28)

* Determine the nginx port at run time to generate a working link under non-port-80 conditions.

* Remove debug code. Sigh.
  • Loading branch information
pingers authored Apr 16, 2018
1 parent e24160f commit 4904a30
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions dsh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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."
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 4904a30

Please sign in to comment.