Skip to content

PHP_FPM_POST_INIT_SCRIPT is not working #87

@jvillegasd

Description

@jvillegasd

Summary

After yesterday updates on Docker registries and migrating my old tiredofit nginx-php-fpm 8.3 debian image to nfrastack/nginx-php-fpm:8.4-debian_trixie_faflopza I noticed that scripts added PHP_FPM_POST_INIT_SCRIPT are not being executed. I read the current codebase and there is no reference to this env variable anymore.

This is one of the scripts it used to be executed by using this env var in old versions:

#!/bin/bash

set -e

# Laravel production steps
echo "Caching config, route, view and optimize..."
php /www/html/artisan config:cache
php /www/html/artisan route:cache
php /www/html/artisan view:cache
php /www/html/artisan optimize

echo "Migration database..."
php /www/html/artisan migrate --force

Environment

  • Image version / tag: nfrastack/nginx-php-fpm:8.4-debian_trixie_faflopza
  • Host OS: ubuntu 24.04.2 lts
´´´

Image: nfrastack/nginx-php-fpm | Version 8.0.0pre Type 'image_changelog' for details
Repository/Documentation: https://github.com/nfrastack/container-nginx-php-fpm/
License: MIT - 2025 © Nfrastack | More info: https://www.nfrastack.com

For support, development, updates, and feature request fulfillment, fund my work.

2025-10-01.15:03:52 [NOTICE] ** [container] Advanced container functionality disabled
2025-10-01.15:03:52 [NOTICE] ** [container] Timezone: Setting to 'America/Bogota' from 'Etc/GMT'
2025-10-01.10:03:53 [NOTICE] ** [messaging] Container configured to route mail via SMTP to 'postfix-relay'
2025-10-01.10:03:57 [INFO] ** [nginx] [configure_site] Configuring site 'sir-backoffice'
2025-10-01.10:03:57 [INFO] ** [nginx] [configure_site] [sir-backoffice] Enabled Client Caching
2025-10-01.10:04:49 [INFO] ** [php-fpm] [configure_site] Configuring site 'sir-backoffice'
2025-10-01.10:04:49 [NOTICE] ** [php-fpm] Creating sample index.php
2025-10-01.10:04:53 [STARTING] ** [nginx] [1] Starting nginx 1.29.1
2025-10-01.10:04:54 [STARTING] ** [php-fpm] [1] Starting php-fpm 8.4.12

´´´

You can see in the container logs that script echo do not appear here.

Possible fixes

This code snippet did the magic in older version

    if [ -n "${PHP_FPM_POST_INIT_SCRIPT}" ] ; then
        print_debug "Found Post Init Scripts"
        post_scripts=$(echo "${PHP_FPM_POST_INIT_SCRIPT}" | tr "," "\n")
        for post_script in $post_scripts; do
            if [ -f "${post_script}" ] ; then
                print_debug "Executing post init script '${post_script}'"
                chmod +x "${post_script}"
                "${post_script}"
            else
                print_error "Tried to run post script '${post_script}' but it does not exist!"
            fi
        done
    fi

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions