Skip to content

Commit 4904a30

Browse files
authored
Determine the nginx port at run time to generate a working link under… (#28)
* Determine the nginx port at run time to generate a working link under non-port-80 conditions. * Remove debug code. Sigh.
1 parent e24160f commit 4904a30

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

dsh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@ MACHINE='default'
1212
# exists in global DNS, which may cause issues reassigning it with dnsmasq.
1313
export DOMAIN=${DOMAIN:-'test'}
1414

15+
# Nginx proxy exposed port. Useful when using something other than 80.
16+
export NGINX_PORT=$(docker port nginx-proxy | awk -F ':' '{print $2}')
17+
1518
# Used as the prefix for docker networking, container naming and nginx hostname.
16-
export PROJECT=$(basename ${PWD} | sed 's/[-_]//g')
19+
export PROJECT=$(basename ${PWD})
1720

1821
# Determine the OS type of the host machine.
1922
if [ "$(uname)" == "Darwin" ]; then
@@ -53,8 +56,9 @@ dsh_start() {
5356
notice "Starting project containers."
5457
docker-compose up -d
5558
setup_xdebug
59+
export URL="http://${PROJECT}.${DOMAIN}$(if [ ! $NGINX_PORT -eq '80' ]; then echo ":$NGINX_PORT"; fi)"
5660
notice "Please wait about 10 seconds for the database to settle.
57-
You can now access the site from http://${PROJECT}.${DOMAIN}.
61+
You can now access the site from ${URL}.
5862
Project files are available in /code, You may need to build and install your
5963
project before it starts working.
6064
Connecting via ./dsh shell and running robo build is a common next step."
@@ -242,6 +246,9 @@ setup_nginx_proxy() {
242246

243247
if ! docker ps | grep "nginx-proxy" > /dev/null; then
244248
error "jwilder/nginx-proxy could not be started."
249+
else
250+
# Update the nginx port as it wasn't running initially.
251+
export NGINX_PORT=$(docker port nginx-proxy | awk -F ':' '{print $2}')
245252
fi
246253
}
247254

0 commit comments

Comments
 (0)