From c00c72c5a3e00c9cb4661ab7c081975bc0aa4736 Mon Sep 17 00:00:00 2001 From: James Deathe Date: Thu, 3 Oct 2019 11:25:20 +0100 Subject: [PATCH 1/8] #253: Updates upstream source to 1.11.1. --- .dockerignore | 25 +++---- .gitignore | 5 +- CHANGELOG.md | 14 ++++ Dockerfile | 2 +- Makefile | 45 +++++++++++-- README.md | 4 +- docs/testing.md | 13 ++++ src/usr/bin/healthcheck | 116 ++++++++++---------------------- src/usr/sbin/httpd-wrapper | 5 +- src/var/www/cgi-bin/php-wrapper | 18 ++++- test/health_status | 65 +++++++++--------- testing.md | 21 ------ 12 files changed, 170 insertions(+), 163 deletions(-) create mode 100644 docs/testing.md delete mode 100644 testing.md diff --git a/.dockerignore b/.dockerignore index 9920c41..5f20999 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,14 +1,15 @@ -.env -.env.example -.git -.gitignore -dist -images -test -docker-compose.yml -LICENSE -README-short.txt -*.md +/.env +/.env.example +/.git +/.gitignore +/dist +/docs +/images +/test +/docker-compose.yml +/LICENSE +/README-short.txt +/*.md !README.md **/*.mk -**/Makefile \ No newline at end of file +**/Makefile diff --git a/.gitignore b/.gitignore index 01faf4b..3bd889e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ -.env -packages -dist \ No newline at end of file +/.env +/dist diff --git a/CHANGELOG.md b/CHANGELOG.md index 203eb6e..20f0f28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,20 @@ Summary of release changes. +### 1.13.3 - Unreleased + +- Updates source image to [1.11.1](https://github.com/jdeathe/centos-ssh/releases/tag/1.11.1). +- Updates `test/health_status` helper script with for consistency. +- Updates Makefile target `logs` to accept `[OPTIONS]` (e.g `make -- logs -ft`). +- Updates info/error output for consistency. +- Updates healthcheck failure messages to remove EOL character that is rendered in status response. +- Updates wrapper script; only emit "waiting on" info message if bootstrap hasn't completed. +- Updates ordering of Tags and respective Dockerfile links in README.md for readability. +- Adds improved test workflow; added `test-setup` target to Makefile. +- Adds Makefile target `logsdef` to handle deferred logs output within a target chain. +- Adds `/docs` directory for supplementary documentation and simplify README. +- Fixes validation failure of 0 second --timeout value in `test/health_status`. + ### 1.13.2 - 2019-08-05 - Updates php-hello-world to [0.14.0](https://github.com/jdeathe/php-hello-world/releases/tag/0.14.0). diff --git a/Dockerfile b/Dockerfile index 67d3478..154aae1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM jdeathe/centos-ssh:1.11.0 +FROM jdeathe/centos-ssh:1.11.1 # Use the form ([{fqdn}-]{package-name}|[{fqdn}-]{provider-name}) ARG PACKAGE_NAME="app" diff --git a/Makefile b/Makefile index 6416f1b..35ff77a 100644 --- a/Makefile +++ b/Makefile @@ -25,10 +25,11 @@ Targets: images Show container's image details. load Loads from the distribution package. Requires DOCKER_IMAGE_TAG variable. - logs Display log output from the running container. - logs-delayed Display log output from the running container after - backing off for STARTUP_TIME seconds. This can be - necessary when chaining make targets together. + logs [OPTIONS] Display log output from the container. + logsdef Display log output from the container deferred for + STARTUP_TIME seconds. This will work in a chain + unlike the logs target. + logs-delayed [DEPRECATED] Replaced with logsdef. pause Pause the running container. pull Pull the release image from the registry. Requires the DOCKER_IMAGE_TAG variable. @@ -45,6 +46,7 @@ Targets: stop Stop the container when in a running state. terminate Unpause, stop and remove the container. test Run all test cases. + test-setup Install test dependencies. top [ps OPTIONS] Display the running processes of the container. unpause Unpause the container when in a paused state. @@ -161,6 +163,7 @@ endef _require-docker-image-tag \ _require-docker-release-tag \ _require-package-path \ + _require-root \ _test-prerequisites \ _usage \ all \ @@ -176,6 +179,7 @@ endef images \ load \ logs \ + logsdef \ logs-delayed \ pause \ pull \ @@ -191,6 +195,7 @@ endef stop \ terminate \ test \ + test-setup \ top \ unpause @@ -365,9 +370,17 @@ _require-package-path: exit 1; \ fi +_require-root: + @ if [[ $${EUID} -ne 0 ]]; \ + then \ + >&2 printf -- '%sMust be run as root\n' \ + "$(PREFIX_STEP_NEGATIVE)"; \ + exit 1; \ + fi + _test-prerequisites: ifeq ($(shpec),) - $(error "Please install shpec.") + $(error "Please install shpec. Try: DOCKER_NAME=$(DOCKER_NAME) make test-setup") endif _usage: @@ -581,14 +594,20 @@ install: | \ logs: \ _prerequisites \ _require-docker-container - @ $(docker) logs $(DOCKER_NAME) + @ $(docker) logs \ + $(filter-out $@, $(MAKECMDGOALS)) \ + $(DOCKER_NAME) +%:; @: -logs-delayed: \ +logsdef: \ _prerequisites \ _require-docker-container @ sleep $(STARTUP_TIME) @ $(MAKE) logs +logs-delayed: \ + logsdef + load: \ _prerequisites \ _require-docker-release-tag \ @@ -980,6 +999,18 @@ test: \ "Functional test" @ SHPEC_ROOT=$(SHPEC_ROOT) $(shpec) +test-setup: \ + _require-root + @ printf -- '%s%s\n' \ + "$(PREFIX_STEP)" \ + "Installing shpec" + @ bash -c "$$(curl -LSs \ + https://raw.githubusercontent.com/rylnd/shpec/master/install.sh \ + )" + @ ln -sf \ + /usr/local/bin/shpec \ + /usr/bin/shpec + unpause: \ _prerequisites \ _require-docker-container \ diff --git a/README.md b/README.md index 96bb813..0c7b99f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ### Tags and respective `Dockerfile` links -- `centos-7`, `2.2.2` [(centos-7/Dockerfile)](https://github.com/jdeathe/centos-ssh-apache-php-fcgi/blob/centos-7/Dockerfile) -- `centos-6`, `1.13.2` [(centos-6/Dockerfile)](https://github.com/jdeathe/centos-ssh-apache-php-fcgi/blob/centos-6/Dockerfile) +- [`2.2.2`](https://github.com/jdeathe/centos-ssh-apache-php-fcgi/releases/tag/2.2.2), `centos-7` [(centos-7/Dockerfile)](https://github.com/jdeathe/centos-ssh-apache-php-fcgi/blob/centos-7/Dockerfile) +- [`1.13.2`](https://github.com/jdeathe/centos-ssh-apache-php-fcgi/releases/tag/1.13.2), `centos-6` [(centos-6/Dockerfile)](https://github.com/jdeathe/centos-ssh-apache-php-fcgi/blob/centos-6/Dockerfile) ## Overview diff --git a/docs/testing.md b/docs/testing.md new file mode 100644 index 0000000..540d82d --- /dev/null +++ b/docs/testing.md @@ -0,0 +1,13 @@ +# Testing + +## Functional + +The functional test cases are written in [shpec](https://github.com/rylnd/shpec). + +To run the tests use the `test` Makefile target after building. + +> *Note:* You might need to run via sudo if your environment requires root privileges to run docker. + +``` +$ make build test +``` diff --git a/src/usr/bin/healthcheck b/src/usr/bin/healthcheck index bfe6753..8c56957 100755 --- a/src/usr/bin/healthcheck +++ b/src/usr/bin/healthcheck @@ -75,45 +75,6 @@ function __last_check_passed () fi } -function __print_message () -{ - local -r quiet="${quiet:-false}" - local -r type="${1}" - - local message="${2}" - local prefix - - case "${type}" in - error) - prefix="ERROR: " - ;; - info) - prefix="INFO: " - ;; - *) - message="${type}" - ;; - esac - - if [[ ${quiet} == true ]] \ - && [[ ${type} != error ]] - then - return 0 - elif [[ ${quiet} == true ]] \ - && [[ ${type} == error ]] - then - >&2 printf -- \ - '%s%s\n' \ - "${prefix}" \ - "${message}" - else - printf -- \ - '%s%s\n' \ - "${prefix}" \ - "${message}" - fi -} - function __record_exit_status () { local -r status_directory="${status_path%/*}" @@ -213,38 +174,38 @@ function main () __usage break ;; - -H) - host="${2}" - shift 2 || break - ;; --host=*) host="${1#*=}" shift 1 ;; - -i) - interval="${2}" + -H|--host) + host="${2}" shift 2 || break ;; --interval=*) interval="${1#*=}" shift 1 ;; - -m) - max_time="${2}" + -i|--interval) + interval="${2}" shift 2 || break ;; --max-time=*) max_time="${1#*=}" shift 1 ;; - -u) - url="${2}" + -m|--max-time) + max_time="${2}" shift 2 || break ;; --url=*) url="${1#*=}" shift 1 ;; + -u|--url) + url="${2}" + shift 2 || break + ;; -q|--quiet) quiet="true" shift 1 @@ -257,50 +218,48 @@ function main () if [[ ! ${host} =~ ${pattern_host} ]] then - __print_message \ - "error" \ - "Invalid host." + >&2 printf -- \ + 'ERROR: %s invalid host' \ + "${0##*/}" exit 1 fi if [[ ! ${interval} =~ ${pattern_seconds_in_minute} ]] then - __print_message \ - "error" \ - "Invalid interval." + >&2 printf -- \ + 'ERROR: %s invalid interval' \ + "${0##*/}" exit 1 fi if [[ ! ${max_time} =~ ${pattern_max_time} ]] then - __print_message \ - "error" \ - "Invalid max_time." + >&2 printf -- \ + 'ERROR: %s invalid max_time' \ + "${0##*/}" exit 1 fi if [[ ! ${url} =~ ${pattern_local_url} ]] then - __print_message \ - "error" \ - "Invalid url." + >&2 printf -- \ + 'ERROR: %s invalid url' \ + "${0##*/}" exit 1 fi if ! ps axo command \ | grep -qE '^/usr/bin/python /usr/bin/supervisord' then - __print_message \ - "error" \ - "supervisord not running." + >&2 printf -- \ + "supervisord not running" exit 1 fi if [[ ${system_timezone} != "${zone}" ]] then - __print_message \ - "error" \ - "system-timezone zone mismatch." + >&2 printf -- \ + "system-timezone zone mismatch" exit 1 fi @@ -313,9 +272,8 @@ function main () if [[ ${ENABLE_HTTPD_BOOTSTRAP} == true ]] \ && [[ ! -f /var/lib/misc/httpd-bootstrap ]] then - __print_message \ - "error" \ - "httpd-bootstrap not completed." + >&2 printf -- \ + "httpd-bootstrap not completed" exit 1 fi @@ -323,9 +281,8 @@ function main () && ! ps axo command \ | grep -qE '^/usr/sbin/httpd(\.worker|\.event)? ' then - __print_message \ - "error" \ - "httpd not running." + >&2 printf -- \ + "httpd not running" exit 1 fi @@ -358,14 +315,11 @@ function main () if [[ ${http_code} == 000 ]] \ || [[ ${http_code} -ge 500 ]] then - __print_message \ - "$( - printf -- \ - '%s Host:%s %s' \ - "${http_code}" \ - "${host}" \ - "${url}" - )" + >&2 printf -- \ + '%s Host:%s %s' \ + "${http_code}" \ + "${host}" \ + "${url}" exit 1 fi diff --git a/src/usr/sbin/httpd-wrapper b/src/usr/sbin/httpd-wrapper index 28d331f..d230cb6 100755 --- a/src/usr/sbin/httpd-wrapper +++ b/src/usr/sbin/httpd-wrapper @@ -134,7 +134,8 @@ function main () __get_proxy )" - if [[ ${verbose} == true ]] + if [[ ${verbose} == true ]] \ + && [[ ! -f ${bootstrap_state_file} ]] then printf -- \ 'INFO: %s waiting on %s\n' \ @@ -155,7 +156,7 @@ function main () done set -e - if ! [[ -f ${bootstrap_state_file} ]] + if [[ ! -f ${bootstrap_state_file} ]] then >&2 printf -- \ 'ERROR: %s timed out waiting on %s\n' \ diff --git a/src/var/www/cgi-bin/php-wrapper b/src/var/www/cgi-bin/php-wrapper index 7c78ed7..fc2c1b7 100755 --- a/src/var/www/cgi-bin/php-wrapper +++ b/src/var/www/cgi-bin/php-wrapper @@ -1,5 +1,13 @@ #!/usr/bin/env bash +function __get_proxy () +{ + printf -- \ + '%s -n %s' \ + "${nice}" \ + "${niceness}" +} + function main () { local -r bin="/usr/bin/php-cgi" @@ -9,6 +17,9 @@ function main () local bin_options local option local -a options + local proxy="$( + __get_proxy + )" local tmp="/var/tmp" while [[ "${#}" -gt 0 ]] @@ -22,6 +33,10 @@ function main () tmp="${1#*=}" shift 1 ;; + --tmp) + tmp+=("${2}") + shift 2 + ;; esac done @@ -41,8 +56,7 @@ function main () export TEMP="${tmp}" export TMPDIR="${tmp}" - exec ${nice} \ - -n ${niceness} \ + exec ${proxy} \ ${bin} \ ${bin_options} } diff --git a/test/health_status b/test/health_status index 25e2f38..6aae041 100755 --- a/test/health_status +++ b/test/health_status @@ -1,5 +1,7 @@ #!/usr/bin/env bash +set -e + function __cleanup () { local -r fifo_path="${1}" @@ -71,9 +73,10 @@ function __print_status () function __usage() { cat <<-EOF - Usage: $(basename ${0}) -c [OPTIONS] - $(basename ${0}) --container= [OPTIONS] - $(basename ${0}) [-h|--help] + + Usage: ${0##*/} -c [OPTIONS] + ${0##*/} --container= [OPTIONS] + ${0##*/} [-h|--help] Gets health_status events and returns the status. @@ -116,7 +119,6 @@ function health_status () local until_timestamp local until - # Parse options while [[ "${#}" -gt 0 ]] do case "${1}" in @@ -128,7 +130,11 @@ function health_status () option_monochrome=true shift 1 ;; - -c) + --container=*) + container="${1#*=}" + shift 1 + ;; + -c|--container) if [[ -z ${2} ]] then __usage @@ -136,10 +142,6 @@ function health_status () container="${2}" shift 2 ;; - --container=*) - container="${1#*=}" - shift 1 - ;; -q|--quiet) option_quiet=true shift 1 @@ -148,7 +150,11 @@ function health_status () since_timestamp="${1#*=}" shift 1 ;; - -t) + --timeout=*) + timeout="${1#*=}" + shift 1 + ;; + -t|--timeout) if [[ -z ${2} ]] then __usage @@ -156,10 +162,6 @@ function health_status () timeout="${2}" shift 2 ;; - --timeout=*) - timeout="${1#*=}" - shift 1 - ;; *) __usage ;; @@ -173,9 +175,9 @@ function health_status () if ! [[ ${timeout} =~ ${pattern_timeout} ]] then - printf -- \ - '[ERROR] Invalid --time value.\n' \ - >&2 + >&2 printf -- \ + 'ERROR: %s invalid --timeout value\n' \ + "${0##*/}" __usage fi @@ -198,12 +200,12 @@ function health_status () fi # Fail if operator attempts start time limit before end limit. - if ! [[ ${since_timestamp} =~ ${pattern_timestamp} ]] \ - || (( since_timestamp > until_timestamp )) + if (( timeout > 0 )) && (( since_timestamp > until_timestamp )) \ + || ! [[ ${since_timestamp} =~ ${pattern_timestamp} ]] then - printf -- \ - '[ERROR] Invalid --since value.\n' \ - >&2 + >&2 printf -- \ + 'ERROR: %s invalid --since value\n' \ + "${0##*/}" __usage fi @@ -216,34 +218,33 @@ function health_status () trap \ "__cleanup \"${fifo_path}\"" \ - INT TERM EXIT + EXIT INT TERM mkfifo \ -m 0600 \ "${fifo_path}" + cd / docker events \ --format '{{.Status}}' \ --filter "event=health_status" \ --filter "container=${container}" \ ${since} \ ${until} \ - > "${fifo_path}" \ - & + 0> /dev/null \ + 1> "${fifo_path}" \ + 2> /dev/null \ + & disown pid="${!}" - disown + cd - \ + > /dev/null trap \ "__cleanup \"${fifo_path}\" \"${pid}\"" \ - INT TERM EXIT + EXIT INT TERM while IFS= read -r health_status || [[ -n ${health_status} ]] do - if [[ ${health_status} =~ ${pattern_starting} ]] - then - __print_status "starting" - fi - if [[ ${health_status} =~ ${pattern_healthy} ]] then __print_status "healthy" diff --git a/testing.md b/testing.md deleted file mode 100644 index 894ca28..0000000 --- a/testing.md +++ /dev/null @@ -1,21 +0,0 @@ -# Testing - -## Functional - -### Installation - -The functional test cases are written in [shpec](https://github.com/rylnd/shpec). - -To run the tests install shpec with the installer. - -``` -$ bash -c "$(curl -L https://raw.github.com/rylnd/shpec/master/install.sh)" -``` - -### Usage - -To manually run the test cases, from the project root: - -``` -$ SHPEC_ROOT=test/shpec shpec -``` \ No newline at end of file From 2c1268762b017ebc9e0da52eeccdaf563d3a1fc9 Mon Sep 17 00:00:00 2001 From: James Deathe Date: Thu, 3 Oct 2019 14:34:14 +0100 Subject: [PATCH 2/8] #247: Adds drop-in config for Apache server-status and remove from global config --- CHANGELOG.md | 2 ++ Dockerfile | 2 -- src/etc/httpd/conf.d/00-server-status.conf | 11 +++++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 src/etc/httpd/conf.d/00-server-status.conf diff --git a/CHANGELOG.md b/CHANGELOG.md index 20f0f28..3b3afab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,9 @@ Summary of release changes. - Adds improved test workflow; added `test-setup` target to Makefile. - Adds Makefile target `logsdef` to handle deferred logs output within a target chain. - Adds `/docs` directory for supplementary documentation and simplify README. +- Adds drop-in configuration for `/server-satus`; removes from global Apache configuration. - Fixes validation failure of 0 second --timeout value in `test/health_status`. +- Removes PHP-FPM status handler configuration from the Apache server-status drop-in. ### 1.13.2 - 2019-08-05 diff --git a/Dockerfile b/Dockerfile index 154aae1..674d686 100644 --- a/Dockerfile +++ b/Dockerfile @@ -89,8 +89,6 @@ RUN useradd -r -M -d /var/www/app -s /sbin/nologin app \ -e 's~^LanguagePriority \(.*\)$~#LanguagePriority \1~g' \ -e 's~^ForceLanguagePriority \(.*\)$~#ForceLanguagePriority \1~g' \ -e 's~^AddLanguage \(.*\)$~#AddLanguage \1~g' \ - -e '/#/,/#<\/Location>/ s~^#~~' \ - -e '//,/<\/Location>/ s~Allow from .example.com~Allow from localhost 127.0.0.1~' \ /etc/httpd/conf/httpd.conf \ && { printf -- \ '\n%s\n%s\n%s\n%s\\\n%s%s\\\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n' \ diff --git a/src/etc/httpd/conf.d/00-server-status.conf b/src/etc/httpd/conf.d/00-server-status.conf new file mode 100644 index 0000000..b24ea77 --- /dev/null +++ b/src/etc/httpd/conf.d/00-server-status.conf @@ -0,0 +1,11 @@ + + SetHandler server-status + + Order deny,allow + Deny from all + Allow from localhost 127.0.0.1 + + = 2.4> + Require host localhost 127.0.0.1 + + From 0230be4bf60cffca7d5e75e6b479a0be99e94442 Mon Sep 17 00:00:00 2001 From: James Deathe Date: Thu, 3 Oct 2019 14:49:49 +0100 Subject: [PATCH 3/8] Removes non-applicable changelog entry. --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b3afab..770f21a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,6 @@ Summary of release changes. - Adds `/docs` directory for supplementary documentation and simplify README. - Adds drop-in configuration for `/server-satus`; removes from global Apache configuration. - Fixes validation failure of 0 second --timeout value in `test/health_status`. -- Removes PHP-FPM status handler configuration from the Apache server-status drop-in. ### 1.13.2 - 2019-08-05 From d9e2586d1efc9a834b47da1e031917cfbe520563 Mon Sep 17 00:00:00 2001 From: James Deathe Date: Thu, 3 Oct 2019 18:18:53 +0100 Subject: [PATCH 4/8] #249: Replaces memcached with redis session store. --- CHANGELOG.md | 1 + test/shpec/operation_shpec.sh | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 770f21a..590430c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ Summary of release changes. - Updates healthcheck failure messages to remove EOL character that is rendered in status response. - Updates wrapper script; only emit "waiting on" info message if bootstrap hasn't completed. - Updates ordering of Tags and respective Dockerfile links in README.md for readability. +- Updates session test cases; replace PHP memcached session store with redis. - Adds improved test workflow; added `test-setup` target to Makefile. - Adds Makefile target `logsdef` to handle deferred logs output within a target chain. - Adds `/docs` directory for supplementary documentation and simplify README. diff --git a/test/shpec/operation_shpec.sh b/test/shpec/operation_shpec.sh index c3ebd5c..eb33082 100644 --- a/test/shpec/operation_shpec.sh +++ b/test/shpec/operation_shpec.sh @@ -10,7 +10,7 @@ DOCKER_PORT_MAP_TCP_8443="${DOCKER_PORT_MAP_TCP_8443:-NULL}" function __destroy () { - local -r session_store_name="memcached.pool-1.1.1" + local -r session_store_name="redis.1" local -r session_store_network="bridge_internal_1" # Destroy the session store container @@ -85,10 +85,10 @@ function __is_container_ready () function __setup () { - local -r session_store_alias="memcached_1" - local -r session_store_name="memcached.pool-1.1.1" + local -r session_store_alias="redis_1" + local -r session_store_name="redis.1" local -r session_store_network="bridge_internal_1" - local -r session_store_release="1.3.1" + local -r session_store_release="1.2.1" if [[ -z $(docker network ls -q -f name="${session_store_network}") ]]; then docker network create \ @@ -107,7 +107,7 @@ function __setup () --name ${session_store_name} \ --network ${session_store_network} \ --network-alias ${session_store_alias} \ - jdeathe/centos-ssh-memcached:${session_store_release} \ + jdeathe/centos-ssh-redis:${session_store_release} \ &> /dev/null # Generate a self-signed certificate @@ -667,7 +667,7 @@ ${other_required_apache_modules} function test_custom_configuration () { - local -r session_store_alias="memcached_1" + local -r session_store_alias="redis_1" local -r session_store_network="bridge_internal_1" local apache_access_log_entry="" @@ -2247,7 +2247,7 @@ function test_custom_configuration () &> /dev/null end - describe "PHP memcached session store" + describe "PHP redis session store" __terminate_container \ apache-php.1 \ &> /dev/null @@ -2256,8 +2256,8 @@ function test_custom_configuration () --detach \ --name apache-php.1 \ --publish ${DOCKER_PORT_MAP_TCP_80}:80 \ - --env PHP_OPTIONS_SESSION_SAVE_HANDLER="memcached" \ - --env PHP_OPTIONS_SESSION_SAVE_PATH="${session_store_alias}:11211" \ + --env PHP_OPTIONS_SESSION_SAVE_HANDLER="redis" \ + --env PHP_OPTIONS_SESSION_SAVE_PATH="${session_store_alias}:6379" \ jdeathe/centos-ssh-apache-php:latest \ &> /dev/null @@ -2289,7 +2289,7 @@ function test_custom_configuration () session_start(); \$_SESSION['integer'] = 123; \$_SESSION['float'] = 12345.67890; - \$_SESSION['string'] = '@memcached:#\$£'; + \$_SESSION['string'] = '@ABCabc:#\$£'; session_write_close(); var_dump(\$_SESSION); EOT @@ -2389,7 +2389,7 @@ function test_custom_configuration () ["float"]=> float(12345.6789) ["string"]=> - string(15) "@memcached:#$£" + string(12) "@ABCabc:#$£" }' end end From 2df4d2e8d20c631dc54fe63b95ee8c10cbf42892 Mon Sep 17 00:00:00 2001 From: James Deathe Date: Thu, 3 Oct 2019 19:23:02 +0100 Subject: [PATCH 5/8] #251: Fixes default Apache DirectoryIndex file. --- CHANGELOG.md | 1 + Dockerfile | 2 + .../apache/var/www/public_html/index.html | 9 ++++ .../apache/var/www/public_html/index.php | 10 ++++ test/shpec/operation_shpec.sh | 47 ++++++++++++++++++- 5 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 test/fixture/apache/var/www/public_html/index.html create mode 100644 test/fixture/apache/var/www/public_html/index.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 590430c..82b9aa1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ Summary of release changes. - Adds `/docs` directory for supplementary documentation and simplify README. - Adds drop-in configuration for `/server-satus`; removes from global Apache configuration. - Fixes validation failure of 0 second --timeout value in `test/health_status`. +- Fixes unintentional override of default `DirectoryIndex` in main Apache configuration. ### 1.13.2 - 2019-08-05 diff --git a/Dockerfile b/Dockerfile index 674d686..4b1aef9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -44,6 +44,7 @@ ADD src / # - Limit threads for the application user # - Disable Apache directory indexes and welcome page # - Disable Apache language based content negotiation +# - Prevent unintentional override of default DirectoryIndex # - Custom Apache configuration # - Disable all Apache modules and enable the minimum # - Disable Apache default fcgid configuration; replaced with 00-fcgid.conf @@ -89,6 +90,7 @@ RUN useradd -r -M -d /var/www/app -s /sbin/nologin app \ -e 's~^LanguagePriority \(.*\)$~#LanguagePriority \1~g' \ -e 's~^ForceLanguagePriority \(.*\)$~#ForceLanguagePriority \1~g' \ -e 's~^AddLanguage \(.*\)$~#AddLanguage \1~g' \ + -e '/^Include conf.d\/\*.conf/i DirectoryIndex index.html index.html.var' \ /etc/httpd/conf/httpd.conf \ && { printf -- \ '\n%s\n%s\n%s\n%s\\\n%s%s\\\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n' \ diff --git a/test/fixture/apache/var/www/public_html/index.html b/test/fixture/apache/var/www/public_html/index.html new file mode 100644 index 0000000..eb7bc1c --- /dev/null +++ b/test/fixture/apache/var/www/public_html/index.html @@ -0,0 +1,9 @@ + + + + {{TITLE}} + + + {{BODY}} + + \ No newline at end of file diff --git a/test/fixture/apache/var/www/public_html/index.php b/test/fixture/apache/var/www/public_html/index.php new file mode 100644 index 0000000..34d0efb --- /dev/null +++ b/test/fixture/apache/var/www/public_html/index.php @@ -0,0 +1,10 @@ + + + + {{TITLE}} + + + + {{BODY}} + + \ No newline at end of file diff --git a/test/shpec/operation_shpec.sh b/test/shpec/operation_shpec.sh index eb33082..0014184 100644 --- a/test/shpec/operation_shpec.sh +++ b/test/shpec/operation_shpec.sh @@ -180,6 +180,7 @@ function test_basic_operations () - setenvif_module - status_module - version_module" + local -r content_index_html="$(< test/fixture/apache/var/www/public_html/index.html)" local -r required_apache_modules=" authz_user_module log_config_module @@ -656,6 +657,48 @@ ${other_required_apache_modules} end end + describe "Apache DirectoryIndex" + it "Defaults to index.html" + __terminate_container \ + apache-php.1 \ + &> /dev/null + + docker run \ + --detach \ + --no-healthcheck \ + --name apache-php.1 \ + --publish ${DOCKER_PORT_MAP_TCP_80}:80 \ + --volume ${PWD}/test/fixture/apache/var/www/public_html:/opt/app/public_html:ro \ + jdeathe/centos-ssh-apache-php-fcgi:latest \ + &> /dev/null + + if ! __is_container_ready \ + apache-php.1 \ + ${STARTUP_TIME} \ + "/usr/sbin/httpd(\.worker|\.event)? " \ + "[[ 000 != \$(curl -sI -o /dev/null -w %{http_code} localhost/) ]]" + then + exit 1 + fi + + container_hostname="$( + docker exec \ + apache-php.1 \ + hostname + )" + + curl_get_request="$( + curl -s \ + --header "Host: ${container_hostname}" \ + http://127.0.0.1:${container_port_80}/ + )" + + assert equal \ + "${curl_get_request}" \ + "${content_index_html}" + end + end + __terminate_container \ apache-php.1 \ &> /dev/null @@ -2536,7 +2579,7 @@ describe "jdeathe/centos-ssh-apache-php-fcgi:latest" __destroy __setup test_basic_operations - test_custom_configuration - test_healthcheck + # test_custom_configuration + # test_healthcheck __destroy end \ No newline at end of file From cc66a457ecf5eb187a7fa2acfdd5a82c691e14b6 Mon Sep 17 00:00:00 2001 From: James Deathe Date: Thu, 3 Oct 2019 19:25:52 +0100 Subject: [PATCH 6/8] #251: Reverts uninteded change to test config. --- test/shpec/operation_shpec.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/shpec/operation_shpec.sh b/test/shpec/operation_shpec.sh index 0014184..3cb247f 100644 --- a/test/shpec/operation_shpec.sh +++ b/test/shpec/operation_shpec.sh @@ -2579,7 +2579,7 @@ describe "jdeathe/centos-ssh-apache-php-fcgi:latest" __destroy __setup test_basic_operations - # test_custom_configuration - # test_healthcheck + test_custom_configuration + test_healthcheck __destroy end \ No newline at end of file From aac483e05092d951c1d953ece9758040a91e185c Mon Sep 17 00:00:00 2001 From: James Deathe Date: Mon, 7 Oct 2019 12:24:30 +0100 Subject: [PATCH 7/8] Updates changelog with missing item --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 82b9aa1..1888cca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ Summary of release changes. ### 1.13.3 - Unreleased +- Deprecate Makefile target `logs-delayed`; replaced with `logsdef`. - Updates source image to [1.11.1](https://github.com/jdeathe/centos-ssh/releases/tag/1.11.1). - Updates `test/health_status` helper script with for consistency. - Updates Makefile target `logs` to accept `[OPTIONS]` (e.g `make -- logs -ft`). From 8d235189a7fcc917d28d8bf1f70636247d817c16 Mon Sep 17 00:00:00 2001 From: James Deathe Date: Tue, 8 Oct 2019 15:07:00 +0100 Subject: [PATCH 8/8] Release changes for 2.2.3, 1.13.3 --- CHANGELOG.md | 2 +- Dockerfile | 2 +- README.md | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1888cca..b87d084 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ Summary of release changes. -### 1.13.3 - Unreleased +### 1.13.3 - 2019-10-08 - Deprecate Makefile target `logs-delayed`; replaced with `logsdef`. - Updates source image to [1.11.1](https://github.com/jdeathe/centos-ssh/releases/tag/1.11.1). diff --git a/Dockerfile b/Dockerfile index 4b1aef9..292bb45 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ FROM jdeathe/centos-ssh:1.11.1 ARG PACKAGE_NAME="app" ARG PACKAGE_PATH="/opt/${PACKAGE_NAME}" ARG PACKAGE_RELEASE_VERSION="0.14.0" -ARG RELEASE_VERSION="1.13.2" +ARG RELEASE_VERSION="1.13.3" # ------------------------------------------------------------------------------ # Base install of required packages diff --git a/README.md b/README.md index 0c7b99f..dc13aa7 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ### Tags and respective `Dockerfile` links -- [`2.2.2`](https://github.com/jdeathe/centos-ssh-apache-php-fcgi/releases/tag/2.2.2), `centos-7` [(centos-7/Dockerfile)](https://github.com/jdeathe/centos-ssh-apache-php-fcgi/blob/centos-7/Dockerfile) -- [`1.13.2`](https://github.com/jdeathe/centos-ssh-apache-php-fcgi/releases/tag/1.13.2), `centos-6` [(centos-6/Dockerfile)](https://github.com/jdeathe/centos-ssh-apache-php-fcgi/blob/centos-6/Dockerfile) +- [`2.2.3`](https://github.com/jdeathe/centos-ssh-apache-php-fcgi/releases/tag/2.2.3), `centos-7` [(centos-7/Dockerfile)](https://github.com/jdeathe/centos-ssh-apache-php-fcgi/blob/centos-7/Dockerfile) +- [`1.13.3`](https://github.com/jdeathe/centos-ssh-apache-php-fcgi/releases/tag/1.13.3), `centos-6` [(centos-6/Dockerfile)](https://github.com/jdeathe/centos-ssh-apache-php-fcgi/blob/centos-6/Dockerfile) ## Overview @@ -25,7 +25,7 @@ $ docker run -d \ --name apache-php.1 \ -p 8080:80 \ -e "APACHE_SERVER_NAME=app-1.local" \ - jdeathe/centos-ssh-apache-php-fcgi:2.2.2 + jdeathe/centos-ssh-apache-php-fcgi:2.2.3 ``` Go to `http://{{docker-host}}:8080` using a browser where `{{docker-host}}` is the host name of your docker server and, if all went well, you should see the "Hello, world!" page. @@ -90,7 +90,7 @@ $ docker stop apache-php.1 && \ --env "APACHE_SERVER_NAME=app-1.local" \ --env "APACHE_SSL_PROTOCOL=All -SSLv2 -SSLv3 -TLSv1 -TLSv1.1" \ --env "PHP_OPTIONS_DATE_TIMEZONE=Europe/London" \ - jdeathe/centos-ssh-apache-php-fcgi:2.2.2 + jdeathe/centos-ssh-apache-php-fcgi:2.2.3 ``` #### Environment Variables @@ -204,7 +204,7 @@ $ docker stop apache-php.1 && \ --env "APACHE_SERVER_ALIAS=app-1" \ --env "APACHE_SERVER_NAME=app-1.local" \ --env "APACHE_MOD_SSL_ENABLED=true" \ - jdeathe/centos-ssh-apache-php-fcgi:2.2.2 + jdeathe/centos-ssh-apache-php-fcgi:2.2.3 ``` ##### APACHE_MPM