Skip to content

Commit 2c492ce

Browse files
zeshanziyastasadev
andauthored
fix: use dynamic ports for router and mailpit, fixes #23 (#30)
Co-authored-by: Stanislav Zhuk <[email protected]>
1 parent 053aa16 commit 2c492ce

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

docker-compose.varnish.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ services:
1515
- VIRTUAL_HOST=$DDEV_HOSTNAME
1616
# This defines the ports the service should be accessible from at
1717
# sitename.ddev.site.
18-
- HTTPS_EXPOSE=443:80,8026:8025
19-
- HTTP_EXPOSE=80:80,8025:8025
18+
- HTTPS_EXPOSE=${DDEV_ROUTER_HTTPS_PORT}:80,${DDEV_MAILPIT_HTTPS_PORT}:8025
19+
- HTTP_EXPOSE=${DDEV_ROUTER_HTTP_PORT}:80,${DDEV_MAILPIT_PORT}:8025
2020
volumes:
2121
# This exposes a mount to the host system `.ddev/varnish` directory where
2222
# your default.vcl should be.
@@ -28,4 +28,4 @@ services:
2828
expose:
2929
- "8025"
3030
entrypoint:
31-
/usr/local/bin/docker-varnish-entrypoint -a 0.0.0.0:8025
31+
/usr/local/bin/docker-varnish-entrypoint -a 0.0.0.0:8025

tests/test.bats

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,30 @@ teardown() {
4444
curl -sI "https://${PROJNAME}.ddev.site:8026" | grep -i "https://novarnish.${PROJNAME}.ddev.site:8026/" >/dev/null || (echo "# https://${PROJNAME}.ddev.site:8026 did not redirect" >&3 && exit 1);
4545
}
4646

47+
@test "install from directory with nonstandard port" {
48+
set -eu -o pipefail
49+
cd ${TESTDIR}
50+
ddev config --router-http-port 8080 --router-https-port 8443 --mailpit-http-port 18025 --mailpit-https-port 18026
51+
echo "# ddev get ${DIR} with project ${PROJNAME} in ${TESTDIR} ($(pwd))" >&3
52+
ddev get ${DIR} >/dev/null
53+
ddev restart >/dev/null 2>&1
54+
for url in http://${PROJNAME}.ddev.site:8080/ http://extrahostname.ddev.site:8080/ http://extrafqdn.ddev.site:8080/ https://${PROJNAME}.ddev.site:8443/ https://extrahostname.ddev.site:8443/ https://extrafqdn.ddev.site:8443/ ; do
55+
# It's "Via:" with http and "via:" with https. Tell me why.
56+
echo "# test $url for via:.*varnish header" >&3
57+
curl -sI $url | grep -i "Via:.*varnish" >/dev/null || (echo "# varnish headers not shown for $url" >&3 && exit 1);
58+
echo "# test $url for phpinfo content" >&3
59+
curl -s $url | grep "allow_url_fopen" >/dev/null || (echo "# phpinfo information not shown in curl for $url" >&3 && exit 1);
60+
done
61+
for url in http://novarnish.${PROJNAME}.ddev.site:8080/ http://novarnish.extrahostname.ddev.site:8080/ http://novarnish.extrafqdn.ddev.site:8080/ https://novarnish.${PROJNAME}.ddev.site:8443/ https://novarnish.extrahostname.ddev.site:8443/ https://novarnish.extrafqdn.ddev.site:8443/ ; do
62+
echo "# test $url for phpinfo content" >&3
63+
curl -s $url | grep "allow_url_fopen" >/dev/null || (echo "# phpinfo information not shown in curl for $url" >&3 && exit 1);
64+
done
65+
echo "# test http://${PROJNAME}.ddev.site:18025 for http novarnish redirect" >&3
66+
curl -sI "http://${PROJNAME}.ddev.site:18025" | grep -i "http://novarnish.${PROJNAME}.ddev.site:18025/" >/dev/null || (echo "# http://${PROJNAME}.ddev.site:18025 did not redirect" >&3 && exit 1);
67+
echo "# test https://${PROJNAME}.ddev.site:18026 for https novarnish redirect" >&3
68+
curl -sI "https://${PROJNAME}.ddev.site:18026" | grep -i "https://novarnish.${PROJNAME}.ddev.site:18026/" >/dev/null || (echo "# https://${PROJNAME}.ddev.site:18026 did not redirect" >&3 && exit 1);
69+
}
70+
4771
@test "install from release" {
4872
set -eu -o pipefail
4973
cd ${TESTDIR} || ( printf "unable to cd to ${TESTDIR}\n" && exit 1 )

0 commit comments

Comments
 (0)