diff --git a/Dockerfiles/prod/data/docker-entrypoint.d/31-postfix.sh b/Dockerfiles/prod/data/docker-entrypoint.d/31-postfix.sh
index 10a21e0..33c9222 100755
--- a/Dockerfiles/prod/data/docker-entrypoint.d/31-postfix.sh
+++ b/Dockerfiles/prod/data/docker-entrypoint.d/31-postfix.sh
@@ -29,7 +29,7 @@ set_postfix() {
else
catch_all="$( env_get "${env_varname}" )"
if [ "${catch_all}" = "1" ]; then
- log "info" "Enabling postfix catch-all" "${debug}"
+ log "info" "\$${env_varname} set to 1. Enabling postfix catch-all" "${debug}"
# Configure PHP
{
@@ -61,11 +61,10 @@ set_postfix() {
run "newaliases" "${debug}"
elif [ "${catch_all}" = "0" ]; then
- log "info" "Disabling postfix catch-all" "${debug}"
+ log "info" "\$${env_varname} set to 0. Disabling postfix catch-all" "${debug}"
else
- log "err" "Invalid value for \$${env_varname}" "${debug}"
- log "err" "Only 1 (for on) or 0 (for off) are allowed" "${debug}"
+ log "err" "Invalid value for \$${env_varname}. Can only be 0 or 1. Prodived: ${catch_all}" "${debug}"
exit 1
fi
fi
diff --git a/README.md b/README.md
index a6a813e..ba1ae07 100644
--- a/README.md
+++ b/README.md
@@ -89,6 +89,76 @@ Have a look at the following table to see all supported environment variables fo
+### Volumes
+
+Have a look at the following table to see all offered volumes for each Docker image flavour.
+
+
+
+
+ | Image |
+ Volumes |
+ Description |
+
+
+
+
+ prod
work |
+ /etc/php-custom.d |
+ Mount this directory into your host computer and add custom \*.ini files in order to alter php behaviour. |
+
+
+ /etc/php-modules.d |
+ Mount this directory into your host computer and add custo \*.so files in order to add your php modules.
Note:Your should then also provide a custom \*.ini file in order to actually load your custom provided module. |
+
+
+ /var/log/php |
+ When setting environment variable DOCKER_LOGS to 0, log files will be available under this directory. |
+
+
+ /var/mail |
+ Emails caught be the postfix catch-all (ENABLE_MAIL=1) will be available in this directory. |
+
+
+ |
+
+
+ | work |
+ /etc/bash-custom.d |
+ Mount this directory into your host computer and add custom configuration files for bash and other tools. |
+
+
+ /shared/backups |
+ Mount this directory into your host computer to access MySQL backups created by mysqldump-secure. |
+
+
+
+
+
+### Ports
+
+Have a look at the following table to see all offered exposed ports for each Docker image flavour.
+
+
+
+
+ | Image |
+ Port |
+ Description |
+
+
+
+
+ base mods prod work |
+ 9000 |
+ PHP-FPM listening port |
+
+
+
+
+
+
+
Modules
diff --git a/tests/.lib.sh b/tests/.lib.sh
index 43f0c6b..119ad42 100755
--- a/tests/.lib.sh
+++ b/tests/.lib.sh
@@ -150,6 +150,21 @@ function docker_exec() {
}
+###
+### Get docker name
+###
+function docker_name() {
+ local did="${1}"
+ local name=
+ name="$( docker ps | grep "${did}" | awk '{print $(NF)}' )"
+
+ if [ -z "${name}" ]; then
+ return 1
+ fi
+ echo "${name}"
+}
+
+
###
### Stop container
###
diff --git a/tests/prod/02-test-env-docker_logs.sh b/tests/prod/02-test-env-docker_logs.sh
index 9fca98f..da4fd86 100755
--- a/tests/prod/02-test-env-docker_logs.sh
+++ b/tests/prod/02-test-env-docker_logs.sh
@@ -19,7 +19,6 @@ FLAVOUR="${3}"
# Tests
############################################################
-
###
### Docker logs
###
diff --git a/tests/prod/03-test-env-enable_mail.sh b/tests/prod/03-test-env-enable_mail.sh
new file mode 100755
index 0000000..efafb0d
--- /dev/null
+++ b/tests/prod/03-test-env-enable_mail.sh
@@ -0,0 +1,66 @@
+#!/usr/bin/env bash
+
+set -e
+set -u
+set -o pipefail
+
+CWD="$(cd -P -- "$(dirname -- "$0")" && pwd -P)"
+
+IMAGE="${1}"
+VERSION="${2}"
+FLAVOUR="${3}"
+
+# shellcheck disable=SC1090
+. "${CWD}/../.lib.sh"
+
+
+
+############################################################
+# Tests
+############################################################
+
+###
+### Postfix
+###
+MOUNTPOINT="$( mktemp --directory )"
+did="$( docker_run "${IMAGE}:${VERSION}-${FLAVOUR}" "-e DEBUG_ENTRYPOINT=2 -e NEW_UID=$(id -u) -e NEW_GID=$(id -g) -e ENABLE_MAIL=1 -v ${MOUNTPOINT}:/var/mail" )"
+run "sleep 10"
+
+if ! run "docker logs ${did} 2>&1 | grep -q 'ENABLE_MAIL'"; then
+ docker_logs "${did}" || true
+ docker_stop "${did}" || true
+ echo "Failed"
+ exit 1
+fi
+
+if [ ! -f "${MOUNTPOINT}/devilbox" ]; then
+ echo "Mail file does not exist: ${MOUNTPOINT}/devilbox"
+ ls -lap ${MOUNTPOINT}/
+ docker_logs "${did}" || true
+ docker_stop "${did}" || true
+ echo "Failed"
+ exit 1
+fi
+if [ ! -r "${MOUNTPOINT}/devilbox" ]; then
+ echo "Mail file is not readable"
+ ls -lap ${MOUNTPOINT}/
+ docker_logs "${did}" || true
+ docker_stop "${did}" || true
+ echo "Failed"
+ exit 1
+fi
+
+# Send test email
+docker_exec "${did}" "php -r \"mail('mailtest@devilbox.org', 'the subject', 'the message');\""
+run "sleep 5"
+
+if ! run "grep 'the subject' ${MOUNTPOINT}/devilbox"; then
+ docker_logs "${did}" || true
+ docker_stop "${did}" || true
+ echo "Failed"
+ "run cat ${MOUNTPOINT}/devilbox"
+ exit 1
+fi
+
+docker_stop "${did}"
+run "rm -rf ${MOUNTPOINT}" || true
diff --git a/tests/prod/04-test-env-forward_ports_to_localhost.sh b/tests/prod/04-test-env-forward_ports_to_localhost.sh
new file mode 100755
index 0000000..d6cc7e4
--- /dev/null
+++ b/tests/prod/04-test-env-forward_ports_to_localhost.sh
@@ -0,0 +1,50 @@
+#!/usr/bin/env bash
+
+set -e
+set -u
+set -o pipefail
+
+CWD="$(cd -P -- "$(dirname -- "$0")" && pwd -P)"
+
+IMAGE="${1}"
+VERSION="${2}"
+FLAVOUR="${3}"
+
+# shellcheck disable=SC1090
+. "${CWD}/../.lib.sh"
+
+
+
+############################################################
+# Tests
+############################################################
+
+###
+### Socat forwarding
+###
+
+# Start mysql container
+mdid="$( docker_run "mysql:5.6" "-e MYSQL_ALLOW_EMPTY_PASSWORD=yes" )"
+mname="$( docker_name "${mdid}" )"
+run "sleep 5"
+
+did="$( docker_run "${IMAGE}:${VERSION}-${FLAVOUR}" "-e DEBUG_ENTRYPOINT=2 -e FORWARD_PORTS_TO_LOCALHOST=3306:${mname}:3306 --link ${mname}" )"
+if ! run "docker logs ${did} 2>&1 | grep 'Forwarding ${mname}:3306'"; then
+ docker_logs "${did}" || true
+ docker_stop "${did}" || true
+ echo "Failed"
+ exit 1
+fi
+
+# Test connectivity
+docker_exec "${did}" "ping -c 1 ${mname}"
+docker_exec "${did}" "echo | nc -w 1 ${mname} 3306"
+docker_exec "${did}" "echo | nc -w 1 127.0.0.1 3306"
+
+# Only work container has mysql binary installed
+if [ "${FLAVOUR}" = "work" ]; then
+ docker_exec "${did}" "mysql --user=root --password= --host=${mname} -e 'SHOW DATABASES;'"
+ docker_exec "${did}" "mysql --user=root --password= --host=127.0.0.1 -e 'SHOW DATABASES;'"
+fi
+docker_stop "${mdid}"
+docker_stop "${did}"
diff --git a/tests/prod/05-test-mount-custom_ini.sh b/tests/prod/05-test-mount-custom_ini.sh
new file mode 100755
index 0000000..f802f1c
--- /dev/null
+++ b/tests/prod/05-test-mount-custom_ini.sh
@@ -0,0 +1,124 @@
+#!/usr/bin/env bash
+
+set -e
+set -u
+set -o pipefail
+
+CWD="$(cd -P -- "$(dirname -- "$0")" && pwd -P)"
+
+IMAGE="${1}"
+VERSION="${2}"
+FLAVOUR="${3}"
+
+# shellcheck disable=SC1090
+. "${CWD}/../.lib.sh"
+
+
+
+############################################################
+# Tests
+############################################################
+
+###
+### Test Nginx with PHP-FPM
+###
+WWW_PORT="12345"
+DOC_ROOT_HOST="$( mktemp -d )"
+DOC_ROOT_CONT="/var/www/default"
+
+CONFIG_HOST="$( mktemp -d )"
+CONFIG_CONT="/etc/nginx/conf.d"
+
+PHP_INI_HOST="$( mktemp -d )"
+PHP_INI_CONT="/etc/php-custom.d"
+
+echo "post_max_size = 17M" > "${PHP_INI_HOST}/post.ini"
+echo " "${DOC_ROOT_HOST}/index.php"
+
+
+# Start PHP-FPM
+did="$( docker_run "${IMAGE}:${VERSION}-${FLAVOUR}" "-e DEBUG_ENTRYPOINT=2 -v ${DOC_ROOT_HOST}:${DOC_ROOT_CONT} -v ${PHP_INI_HOST}:${PHP_INI_CONT}" )"
+name="$( docker_name "${did}" )"
+
+# Nginx.conf
+{
+ echo "server {"
+ echo " server_name _;"
+ echo " listen 80;"
+ echo " root ${DOC_ROOT_CONT};"
+ echo " index index.php;"
+ echo " location ~* \.php\$ {"
+ echo " fastcgi_index index.php;"
+ echo " fastcgi_pass ${name}:9000;"
+ echo " include fastcgi_params;"
+ echo " fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;"
+ echo " fastcgi_param SCRIPT_NAME \$fastcgi_script_name;"
+ echo " }"
+ echo "}"
+} > "${CONFIG_HOST}/php.conf"
+
+
+# Start Nginx
+ndid="$( docker_run "nginx:stable" "-v ${DOC_ROOT_HOST}:${DOC_ROOT_CONT} -v ${CONFIG_HOST}:${CONFIG_CONT} -p ${WWW_PORT}:80 --link ${name}" )"
+
+# Check entrypoint
+if ! run "docker logs ${did} | grep 'post.ini'"; then
+ run "rm -rf ${DOC_ROOT_HOST}"
+ run "rm -rf ${CONFIG_HOST}"
+ run "rm -rf ${PHP_INI_HOST}"
+ docker_logs "${ndid}" || true
+ docker_logs "${did}" || true
+ docker_stop "${ndid}" || true
+ docker_stop "${did}" || true
+ echo "Failed"
+ exit 1
+fi
+
+# Check PHP connectivity
+if ! run "curl -q 127.0.0.1:${WWW_PORT}/index.php >/dev/null 2>&1"; then
+ run "rm -rf ${DOC_ROOT_HOST}"
+ run "rm -rf ${CONFIG_HOST}"
+ run "rm -rf ${PHP_INI_HOST}"
+ docker_logs "${ndid}" || true
+ docker_logs "${did}" || true
+ docker_stop "${ndid}" || true
+ docker_stop "${did}" || true
+ echo "Failed"
+ exit 1
+fi
+
+# Check modified php.ini
+if ! docker_exec "${did}" "php -r \"echo ini_get('post_max_size');\" | grep '17M'"; then
+ docker_exec "${did}" "php -r \"echo ini_get('post_max_size');\""
+ run "rm -rf ${DOC_ROOT_HOST}"
+ run "rm -rf ${CONFIG_HOST}"
+ run "rm -rf ${PHP_INI_HOST}"
+ docker_logs "${ndid}" || true
+ docker_logs "${did}" || true
+ docker_stop "${ndid}" || true
+ docker_stop "${did}" || true
+ echo "Failed"
+ exit 1
+fi
+
+# Check modified php.ini
+if ! run "curl -q 127.0.0.1:${WWW_PORT}/index.php 2>/dev/null | grep post_max_size | grep '17M'"; then
+ docker_exec "${did}" "php -r \"echo ini_get('post_max_size');\""
+ run "rm -rf ${DOC_ROOT_HOST}"
+ run "rm -rf ${CONFIG_HOST}"
+ run "rm -rf ${PHP_INI_HOST}"
+ docker_logs "${ndid}" || true
+ docker_logs "${did}" || true
+ docker_stop "${ndid}" || true
+ docker_stop "${did}" || true
+ echo "Failed"
+ exit 1
+fi
+
+
+# Cleanup
+docker_stop "${did}"
+docker_stop "${ndid}"
+run "rm -rf ${DOC_ROOT_HOST}"
+run "rm -rf ${CONFIG_HOST}"
+run "rm -rf ${PHP_INI_HOST}"
diff --git a/tests/work/01-test-env-mysqldump-secure.sh b/tests/work/01-test-env-mysqldump-secure.sh
new file mode 100755
index 0000000..89fc333
--- /dev/null
+++ b/tests/work/01-test-env-mysqldump-secure.sh
@@ -0,0 +1,54 @@
+#!/usr/bin/env bash
+
+set -e
+set -u
+set -o pipefail
+
+CWD="$(cd -P -- "$(dirname -- "$0")" && pwd -P)"
+
+IMAGE="${1}"
+VERSION="${2}"
+FLAVOUR="${3}"
+
+# shellcheck disable=SC1090
+. "${CWD}/../.lib.sh"
+
+
+
+############################################################
+# Tests
+############################################################
+
+###
+### Mysqldump-secure
+###
+MYSQL_ROOT_PASSWORD="toor"
+MOUNTPOINT="$( mktemp --directory )"
+
+# Start mysql container
+mdid="$( docker_run "mysql:5.6" "-e MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}" )"
+mname="$( docker_name "${mdid}" )"
+run "sleep 5"
+
+# Start PHP-FPM container
+did="$( docker_run "${IMAGE}:${VERSION}-${FLAVOUR}" "-e DEBUG_ENTRYPOINT=2 -e NEW_UID=$(id -u) -e NEW_GID=$(id -g) -e FORWARD_PORTS_TO_LOCALHOST=3306:${mname}:3306 -e MYSQL_BACKUP_USER=root -e MYSQL_BACKUP_PASS=${MYSQL_ROOT_PASSWORD} -e MYSQL_BACKUP_HOST=127.0.0.1 -v ${MOUNTPOINT}:/shared/backups --link ${mname}" )"
+
+docker_exec "${did}" mysqldump-secure
+
+if [ ! -d "${MOUNTPOINT}/mysql" ]; then
+ echo "MySQL backup dir does not exist: ${MOUNTPOINT}/mysql"
+ ls -lap ${MOUNTPOINT}/
+ docker_logs "${did}"
+ docker_logs "${mdid}"
+ docker_stop "${did}"
+ docker_stop "${mdid}"
+ run "rm -rf ${MOUNTPOINT}" || true
+ exit 1
+fi
+
+run "ls -lap ${MOUNTPOINT}/mysql/ | grep -E 'mysql\.sql\.gz'"
+run "ls -lap ${MOUNTPOINT}/mysql/ | grep -E 'mysql\.sql\.gz\.info'"
+
+docker_stop "${did}"
+docker_stop "${mdid}"
+run "rm -rf ${MOUNTPOINT}" || true