mirror of
https://github.com/devilbox/docker-php-fpm.git
synced 2025-12-10 11:01:14 +00:00
Allow for custom user-supplied startup scripts
This commit is contained in:
49
Dockerfiles/prod/data/docker-entrypoint.d/310-custom-startup-scripts.sh
Executable file
49
Dockerfiles/prod/data/docker-entrypoint.d/310-custom-startup-scripts.sh
Executable file
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
|
||||
############################################################
|
||||
# Functions
|
||||
############################################################
|
||||
|
||||
###
|
||||
### Execute custom uesr-supplied scripts
|
||||
###
|
||||
execute_custom_scripts() {
|
||||
local script_dir="${1}"
|
||||
local debug="${2}"
|
||||
|
||||
if [ ! -d "${script_dir}" ]; then
|
||||
run "mkdir -p ${script_dir}" "${debug}"
|
||||
fi
|
||||
script_files="$( find "${script_dir}" -type f -iname '*.sh' )"
|
||||
|
||||
# loop over them line by line
|
||||
IFS='
|
||||
'
|
||||
for script_f in ${script_files}; do
|
||||
script_name="$( basename "${script_f}" )"
|
||||
log "info" "Executing custom startup script: ${script_name}" "${debug}"
|
||||
if ! bash "${script_f}"; then
|
||||
log "err" "Failed to execute script" "${debug}"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
############################################################
|
||||
# Sanity Checks
|
||||
############################################################
|
||||
|
||||
if ! command -v find >/dev/null 2>&1; then
|
||||
echo "find not found, but required."
|
||||
exit 1
|
||||
fi
|
||||
if ! command -v basename >/dev/null 2>&1; then
|
||||
echo "basename not found, but required."
|
||||
exit 1
|
||||
fi
|
||||
@@ -178,6 +178,13 @@ enable_modules "ENABLE_MODULES" "${DEBUG_LEVEL}"
|
||||
disable_modules "DISABLE_MODULES" "${DEBUG_LEVEL}"
|
||||
|
||||
|
||||
###
|
||||
### Run custom user supplied scripts
|
||||
###
|
||||
execute_custom_scripts "/startup.d" "${DEBUG_LEVEL}"
|
||||
|
||||
|
||||
###
|
||||
###
|
||||
### Startup
|
||||
###
|
||||
|
||||
@@ -206,6 +206,12 @@ run "chmod 0755 /shared/httpd" "${DEBUG_LEVEL}"
|
||||
update_ca_certificates "/ca" "${DEBUG_LEVEL}"
|
||||
|
||||
|
||||
###
|
||||
### Run custom user supplied scripts
|
||||
###
|
||||
execute_custom_scripts "/startup.d" "${DEBUG_LEVEL}"
|
||||
|
||||
|
||||
###
|
||||
### Startup
|
||||
###
|
||||
|
||||
@@ -760,7 +760,7 @@ Have a look at the following table to see all offered volumes for each Docker im
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td rowspan="5"><strong>prod</strong><br/><br/><strong>work</strong></td>
|
||||
<td rowspan="6"><strong>prod</strong><br/><br/><strong>work</strong></td>
|
||||
<td><code>/etc/php-custom.d</code></td>
|
||||
<td>Mount this directory into your host computer and add custom <code>\*.ini</code> files in order to alter php behaviour.</td>
|
||||
</tr>
|
||||
@@ -772,6 +772,10 @@ Have a look at the following table to see all offered volumes for each Docker im
|
||||
<td><code>/etc/php-modules.d</code></td>
|
||||
<td>Mount this directory into your host computer and add custo <code>\*.so</code> files in order to add your php modules.<br/><br/><strong>Note:</strong>Your should then also provide a custom <code>\*.ini</code> file in order to actually load your custom provided module.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>/startup.d</code></td>
|
||||
<td>Any executable scripts ending by <code>\*.sh</code> found in this directory will be executed during startup. This is useful to supply additional commands (such as installing custom software) when the container starts up.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>/var/log/php</code></td>
|
||||
<td>When setting environment variable <code>DOCKER_LOGS</code> to <code>0</code>, log files will be available under this directory.</td>
|
||||
|
||||
Reference in New Issue
Block a user