diff --git a/7.4/Dockerfile.rhel7 b/7.4/Dockerfile.rhel7 index 86b0da2c3..99dfee4dc 100644 --- a/7.4/Dockerfile.rhel7 +++ b/7.4/Dockerfile.rhel7 @@ -66,7 +66,8 @@ ENV PHP_CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/php/ \ HTTPD_DATA_PATH=/var/www \ HTTPD_DATA_ORIG_PATH=/opt/rh/httpd24/root/var/www \ HTTPD_VAR_PATH=/opt/rh/httpd24/root/var \ - SCL_ENABLED=rh-php74 + SCL_ENABLED=rh-php74 \ + HOME=/opt/app-root # Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH COPY ./s2i/bin/ $STI_SCRIPTS_PATH diff --git a/7.4/Dockerfile.rhel8 b/7.4/Dockerfile.rhel8 index 8651b85a6..69af26180 100644 --- a/7.4/Dockerfile.rhel8 +++ b/7.4/Dockerfile.rhel8 @@ -65,7 +65,8 @@ ENV PHP_CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/php/ \ HTTPD_VAR_RUN=/var/run/httpd \ HTTPD_DATA_PATH=/var/www \ HTTPD_DATA_ORIG_PATH=/var/www \ - HTTPD_VAR_PATH=/var + HTTPD_VAR_PATH=/var \ + HOME=/opt/app-root # Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH COPY ./s2i/bin/ $STI_SCRIPTS_PATH diff --git a/8.0/Dockerfile.rhel8 b/8.0/Dockerfile.rhel8 index dc52ef1cb..f7a9524a3 100644 --- a/8.0/Dockerfile.rhel8 +++ b/8.0/Dockerfile.rhel8 @@ -65,7 +65,8 @@ ENV PHP_CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/php/ \ HTTPD_VAR_RUN=/var/run/httpd \ HTTPD_DATA_PATH=/var/www \ HTTPD_DATA_ORIG_PATH=/var/www \ - HTTPD_VAR_PATH=/var + HTTPD_VAR_PATH=/var \ + HOME=/opt/app-root # Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH COPY ./s2i/bin/ $STI_SCRIPTS_PATH diff --git a/8.0/Dockerfile.rhel9 b/8.0/Dockerfile.rhel9 index 376238939..82060d46f 100644 --- a/8.0/Dockerfile.rhel9 +++ b/8.0/Dockerfile.rhel9 @@ -70,7 +70,8 @@ ENV PHP_CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/php/ \ HTTPD_VAR_RUN=/var/run/httpd \ HTTPD_DATA_PATH=/var/www \ HTTPD_DATA_ORIG_PATH=/var/www \ - HTTPD_VAR_PATH=/var + HTTPD_VAR_PATH=/var \ + HOME=/opt/app-root # Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH COPY ./s2i/bin/ $STI_SCRIPTS_PATH diff --git a/8.1/Dockerfile.fedora b/8.1/Dockerfile.fedora index ec83b89b5..f2dd240aa 100644 --- a/8.1/Dockerfile.fedora +++ b/8.1/Dockerfile.fedora @@ -64,7 +64,8 @@ ENV PHP_CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/php/ \ HTTPD_VAR_RUN=/var/run/httpd \ HTTPD_DATA_PATH=/var/www \ HTTPD_DATA_ORIG_PATH=/var/www \ - HTTPD_VAR_PATH=/var + HTTPD_VAR_PATH=/var \ + HOME=/opt/app-root # Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH COPY ./s2i/bin/ $STI_SCRIPTS_PATH diff --git a/8.1/Dockerfile.rhel9 b/8.1/Dockerfile.rhel9 index bdd798875..2e0a87aec 100644 --- a/8.1/Dockerfile.rhel9 +++ b/8.1/Dockerfile.rhel9 @@ -71,7 +71,8 @@ ENV PHP_CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/php/ \ HTTPD_VAR_RUN=/var/run/httpd \ HTTPD_DATA_PATH=/var/www \ HTTPD_DATA_ORIG_PATH=/var/www \ - HTTPD_VAR_PATH=/var + HTTPD_VAR_PATH=/var \ + HOME=/opt/app-root # Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH COPY ./s2i/bin/ $STI_SCRIPTS_PATH diff --git a/8.2/Dockerfile.fedora b/8.2/Dockerfile.fedora index c831adf74..f3ee33f72 100644 --- a/8.2/Dockerfile.fedora +++ b/8.2/Dockerfile.fedora @@ -64,7 +64,8 @@ ENV PHP_CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/php/ \ HTTPD_VAR_RUN=/var/run/httpd \ HTTPD_DATA_PATH=/var/www \ HTTPD_DATA_ORIG_PATH=/var/www \ - HTTPD_VAR_PATH=/var + HTTPD_VAR_PATH=/var \ + HOME=/opt/app-root # Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH COPY ./s2i/bin/ $STI_SCRIPTS_PATH diff --git a/8.2/Dockerfile.rhel8 b/8.2/Dockerfile.rhel8 index ef604c03a..2784292cd 100644 --- a/8.2/Dockerfile.rhel8 +++ b/8.2/Dockerfile.rhel8 @@ -65,7 +65,8 @@ ENV PHP_CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/php/ \ HTTPD_VAR_RUN=/var/run/httpd \ HTTPD_DATA_PATH=/var/www \ HTTPD_DATA_ORIG_PATH=/var/www \ - HTTPD_VAR_PATH=/var + HTTPD_VAR_PATH=/var \ + HOME=/opt/app-root # Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH COPY ./s2i/bin/ $STI_SCRIPTS_PATH diff --git a/8.2/Dockerfile.rhel9 b/8.2/Dockerfile.rhel9 index 86e93c301..01444f080 100644 --- a/8.2/Dockerfile.rhel9 +++ b/8.2/Dockerfile.rhel9 @@ -71,7 +71,8 @@ ENV PHP_CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/php/ \ HTTPD_VAR_RUN=/var/run/httpd \ HTTPD_DATA_PATH=/var/www \ HTTPD_DATA_ORIG_PATH=/var/www \ - HTTPD_VAR_PATH=/var + HTTPD_VAR_PATH=/var \ + HOME=/opt/app-root # Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH COPY ./s2i/bin/ $STI_SCRIPTS_PATH diff --git a/test/run b/test/run index cc9000429..d7bbe0c40 100755 --- a/test/run +++ b/test/run @@ -19,6 +19,7 @@ test_ssl test_ssl_own_cert ct_npm_works test_build_from_dockerfile +test_home_not_in_webroot " TEST_CLEAR_ENV="\ @@ -162,6 +163,25 @@ test_config_writeable() { docker run --rm "${IMAGE_NAME}" /bin/bash -c "${run_cmd}" } +test_home_not_in_webroot() { + cid_file=$CID_FILE_DIR/$(mktemp -u -p . --suffix .cid) + docker run -d --cidfile=${cid_file} ${IMAGE_NAME}-testapp + + # Wait for container to initialize fully + test_connection ${test_port} + + info "Testing whether \$HOME points to web server Document root" + local homef=$(docker exec -it $(cat ${cid_file}) /bin/bash -c "echo \$HOME") + ct_check_testcase_result $? + if [ "${homef}" = "${homef##/opt/app-root/src}" ]; then + echo "Home folder not set to Document root" + return 0 + fi + + info "Home folder set to Document root" + return 1 +} + test_clear_env_setup() { local run_cmd="[ -f /etc/php-fpm.d/www.conf ] && grep \"^clear_env = no\" /etc/php-fpm.d/www.conf"