mirror of
https://github.com/devilbox/docker-php-fpm.git
synced 2025-12-11 19:41:16 +00:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4b2a450d1e | ||
|
|
fe379ae977 | ||
|
|
389b962aaf | ||
|
|
503decb518 | ||
|
|
519ae5e8a7 | ||
|
|
a13ad86820 | ||
|
|
b104211a0a | ||
|
|
30a0d45bad |
0
.gitignore
vendored
Executable file → Normal file
0
.gitignore
vendored
Executable file → Normal file
@@ -32,14 +32,23 @@ RUN set -x \
|
||||
|
||||
|
||||
###
|
||||
### Upgrade
|
||||
### Upgrade (install ps)
|
||||
###
|
||||
RUN set -x \
|
||||
&& apt-get update \
|
||||
&& apt-get upgrade -y \
|
||||
&& apt-get install --no-install-recommends --no-install-suggests -y procps \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
|
||||
###
|
||||
### Configure
|
||||
###
|
||||
RUN set -x \
|
||||
&& rm -rf /usr/local/etc/php-fpm.d \
|
||||
&& mkdir -p /usr/local/etc/php-fpm.d
|
||||
|
||||
|
||||
###
|
||||
### Copy files
|
||||
###
|
||||
|
||||
@@ -32,14 +32,23 @@ RUN set -x \
|
||||
|
||||
|
||||
###
|
||||
### Upgrade
|
||||
### Upgrade (install ps)
|
||||
###
|
||||
RUN set -x \
|
||||
&& apt-get update \
|
||||
&& apt-get upgrade -y \
|
||||
&& apt-get install --no-install-recommends --no-install-suggests -y procps \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
|
||||
###
|
||||
### Configure
|
||||
###
|
||||
RUN set -x \
|
||||
&& rm -rf /usr/local/etc/php-fpm.d \
|
||||
&& mkdir -p /usr/local/etc/php-fpm.d
|
||||
|
||||
|
||||
###
|
||||
### Copy files
|
||||
###
|
||||
|
||||
@@ -32,14 +32,23 @@ RUN set -x \
|
||||
|
||||
|
||||
###
|
||||
### Upgrade
|
||||
### Upgrade (install ps)
|
||||
###
|
||||
RUN set -x \
|
||||
&& apt-get update \
|
||||
&& apt-get upgrade -y \
|
||||
&& apt-get install --no-install-recommends --no-install-suggests -y procps \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
|
||||
###
|
||||
### Configure
|
||||
###
|
||||
RUN set -x \
|
||||
&& rm -rf /usr/local/etc/php-fpm.d \
|
||||
&& mkdir -p /usr/local/etc/php-fpm.d
|
||||
|
||||
|
||||
###
|
||||
### Copy files
|
||||
###
|
||||
|
||||
@@ -32,14 +32,23 @@ RUN set -x \
|
||||
|
||||
|
||||
###
|
||||
### Upgrade
|
||||
### Upgrade (install ps)
|
||||
###
|
||||
RUN set -x \
|
||||
&& apt-get update \
|
||||
&& apt-get upgrade -y \
|
||||
&& apt-get install --no-install-recommends --no-install-suggests -y procps \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
|
||||
###
|
||||
### Configure
|
||||
###
|
||||
RUN set -x \
|
||||
&& rm -rf /usr/local/etc/php-fpm.d \
|
||||
&& mkdir -p /usr/local/etc/php-fpm.d
|
||||
|
||||
|
||||
###
|
||||
### Copy files
|
||||
###
|
||||
|
||||
@@ -32,14 +32,23 @@ RUN set -x \
|
||||
|
||||
|
||||
###
|
||||
### Upgrade
|
||||
### Upgrade (install ps)
|
||||
###
|
||||
RUN set -x \
|
||||
&& apt-get update \
|
||||
&& apt-get upgrade -y \
|
||||
&& apt-get install --no-install-recommends --no-install-suggests -y procps \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
|
||||
###
|
||||
### Configure
|
||||
###
|
||||
RUN set -x \
|
||||
&& rm -rf /usr/local/etc/php-fpm.d \
|
||||
&& mkdir -p /usr/local/etc/php-fpm.d
|
||||
|
||||
|
||||
###
|
||||
### Copy files
|
||||
###
|
||||
|
||||
@@ -32,14 +32,23 @@ RUN set -x \
|
||||
|
||||
|
||||
###
|
||||
### Upgrade
|
||||
### Upgrade (install ps)
|
||||
###
|
||||
RUN set -x \
|
||||
&& apt-get update \
|
||||
&& apt-get upgrade -y \
|
||||
&& apt-get install --no-install-recommends --no-install-suggests -y procps \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
|
||||
###
|
||||
### Configure
|
||||
###
|
||||
RUN set -x \
|
||||
&& rm -rf /usr/local/etc/php-fpm.d \
|
||||
&& mkdir -p /usr/local/etc/php-fpm.d
|
||||
|
||||
|
||||
###
|
||||
### Copy files
|
||||
###
|
||||
|
||||
@@ -17,7 +17,9 @@ set_postfix() {
|
||||
local username="${2}"
|
||||
local groupname="${3}"
|
||||
local php_ini_dir="${4}"
|
||||
local debug="${5}"
|
||||
local php_mail_log="${5}"
|
||||
local docker_logs="${6}"
|
||||
local debug="${7}"
|
||||
|
||||
local php_ini_file="${php_ini_dir}/devilbox-runtime-sendmail.ini"
|
||||
local catch_all=
|
||||
@@ -37,9 +39,23 @@ set_postfix() {
|
||||
echo "sendmail_path = $( which sendmail ) -t -i";
|
||||
echo ";mail.force_extra_parameters =";
|
||||
echo "mail.add_x_header = On";
|
||||
echo "mail.log = /var/log/php/mail.log";
|
||||
echo "mail.log = ${php_mail_log}";
|
||||
} > "${php_ini_file}"
|
||||
|
||||
# PHP mail function logs to file
|
||||
if [ "${docker_logs}" != "1" ]; then
|
||||
# Fix PHP mail log file dir/file and permissions
|
||||
if [ ! -d "$( dirname "${php_mail_log}" )" ]; then
|
||||
run "mkdir -p $( dirname "${php_mail_log}" )" "${debug}"
|
||||
fi
|
||||
if [ ! -f "${php_mail_log}" ]; then
|
||||
run "touch ${php_mail_log}" "${debug}"
|
||||
fi
|
||||
run "chown ${username}:${groupname} $( dirname "${php_mail_log}" )" "${debug}"
|
||||
run "chown ${username}:${groupname} ${php_mail_log}" "${debug}"
|
||||
run "chmod 0644 ${php_mail_log}" "${debug}"
|
||||
fi
|
||||
|
||||
# Add Mail dir/file if it does not exist
|
||||
if [ ! -d "/var/mail" ]; then
|
||||
run "mkdir /var/mail" "${debug}"
|
||||
|
||||
@@ -51,6 +51,26 @@ _log_to_files() {
|
||||
# Functions
|
||||
############################################################
|
||||
|
||||
###
|
||||
### Get info if we log to docker logs
|
||||
###
|
||||
is_docker_logs_enabled() {
|
||||
local env_varname="${1}"
|
||||
if env_set "${env_varname}"; then
|
||||
docker_logs="$( env_get "${env_varname}" )"
|
||||
if [ "${docker_logs}" = "1" ]; then
|
||||
# Use docker logs
|
||||
echo "1"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
# Use file based logging
|
||||
echo "0"
|
||||
return 1
|
||||
}
|
||||
|
||||
|
||||
###
|
||||
### Change PHP-FPM logging (file or docker logs)
|
||||
###
|
||||
|
||||
@@ -21,6 +21,9 @@ CONFIG_DIR="/docker-entrypoint.d"
|
||||
# php.ini.d directory
|
||||
PHP_INI_DIR="/usr/local/etc/php/conf.d"
|
||||
|
||||
# This is the log file for any mail related functions
|
||||
PHP_MAIL_LOG="/var/log/mail.log"
|
||||
|
||||
# This file holds error and access log definitions
|
||||
FPM_CONF_LOGFILE="/usr/local/etc/php-fpm.d/logfiles.conf"
|
||||
|
||||
@@ -69,12 +72,6 @@ set_gid "NEW_GID" "${MY_GROUP}" "/home/${MY_USER}" "${DEBUG_LEVEL}"
|
||||
set_timezone "TIMEZONE" "${PHP_INI_DIR}" "${DEBUG_LEVEL}"
|
||||
|
||||
|
||||
###
|
||||
### Setup postfix
|
||||
###
|
||||
set_postfix "ENABLE_MAIL" "${MY_USER}" "${MY_GROUP}" "${PHP_INI_DIR}" "${DEBUG_LEVEL}"
|
||||
|
||||
|
||||
###
|
||||
### Set Logging
|
||||
###
|
||||
@@ -87,6 +84,18 @@ set_docker_logs \
|
||||
"${DEBUG_LEVEL}"
|
||||
|
||||
|
||||
###
|
||||
### Setup postfix
|
||||
###
|
||||
if is_docker_logs_enabled "DOCKER_LOGS" >/dev/null; then
|
||||
# PHP mail function should log to stderr
|
||||
set_postfix "ENABLE_MAIL" "${MY_USER}" "${MY_GROUP}" "${PHP_INI_DIR}" "/proc/self/fd/2" "1" "${DEBUG_LEVEL}"
|
||||
else
|
||||
# PHP mail function should log to file
|
||||
set_postfix "ENABLE_MAIL" "${MY_USER}" "${MY_GROUP}" "${PHP_INI_DIR}" "${PHP_MAIL_LOG}" "0" "${DEBUG_LEVEL}"
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### Validate socat port forwards
|
||||
###
|
||||
|
||||
@@ -21,6 +21,9 @@ CONFIG_DIR="/docker-entrypoint.d"
|
||||
# php.ini.d directory
|
||||
PHP_INI_DIR="/usr/local/etc/php/conf.d"
|
||||
|
||||
# This is the log file for any mail related functions
|
||||
PHP_MAIL_LOG="/var/log/mail.log"
|
||||
|
||||
# This file holds error and access log definitions
|
||||
FPM_CONF_LOGFILE="/usr/local/etc/php-fpm.d/logfiles.conf"
|
||||
|
||||
@@ -69,12 +72,6 @@ set_gid "NEW_GID" "${MY_GROUP}" "/home/${MY_USER}" "${DEBUG_LEVEL}"
|
||||
set_timezone "TIMEZONE" "${PHP_INI_DIR}" "${DEBUG_LEVEL}"
|
||||
|
||||
|
||||
###
|
||||
### Setup postfix
|
||||
###
|
||||
set_postfix "ENABLE_MAIL" "${MY_USER}" "${MY_GROUP}" "${PHP_INI_DIR}" "${DEBUG_LEVEL}"
|
||||
|
||||
|
||||
###
|
||||
### Set Logging
|
||||
###
|
||||
@@ -87,6 +84,18 @@ set_docker_logs \
|
||||
"${DEBUG_LEVEL}"
|
||||
|
||||
|
||||
###
|
||||
### Setup postfix
|
||||
###
|
||||
if is_docker_logs_enabled "DOCKER_LOGS" >/dev/null; then
|
||||
# PHP mail function should log to stderr
|
||||
set_postfix "ENABLE_MAIL" "${MY_USER}" "${MY_GROUP}" "${PHP_INI_DIR}" "/proc/self/fd/2" "1" "${DEBUG_LEVEL}"
|
||||
else
|
||||
# PHP mail function should log to file
|
||||
set_postfix "ENABLE_MAIL" "${MY_USER}" "${MY_GROUP}" "${PHP_INI_DIR}" "${PHP_MAIL_LOG}" "0" "${DEBUG_LEVEL}"
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### Validate socat port forwards
|
||||
###
|
||||
@@ -138,6 +147,21 @@ fix_mds_permissions "${MY_USER}" "${MY_GROUP}" "${DEBUG_LEVEL}"
|
||||
set_mds_settings "MYSQL_BACKUP_USER" "MYSQL_BACKUP_PASS" "MYSQL_BACKUP_HOST" "${DEBUG_LEVEL}"
|
||||
|
||||
|
||||
###
|
||||
### Fix mountpoint permissions
|
||||
###
|
||||
if [ ! -d "/shared/backups" ]; then
|
||||
run "mkdir -p /shared/backups" "${DEBUG_LEVEL}"
|
||||
fi
|
||||
if [ ! -d "/shared/httpd" ]; then
|
||||
run "mkdir -p /shared/httpd" "${DEBUG_LEVEL}"
|
||||
fi
|
||||
run "chown ${MY_USER}:${MY_GROUP} /shared/backups" "${DEBUG_LEVEL}"
|
||||
run "chown ${MY_USER}:${MY_GROUP} /shared/httpd" "${DEBUG_LEVEL}"
|
||||
run "chmod 0755 /shared/backups" "${DEBUG_LEVEL}"
|
||||
run "chmod 0755 /shared/httpd" "${DEBUG_LEVEL}"
|
||||
|
||||
|
||||
###
|
||||
### Startup
|
||||
###
|
||||
|
||||
@@ -32,14 +32,23 @@ RUN set -x \
|
||||
|
||||
|
||||
###
|
||||
### Upgrade
|
||||
### Upgrade (install ps)
|
||||
###
|
||||
RUN set -x \
|
||||
&& apt-get update \
|
||||
&& apt-get upgrade -y \
|
||||
&& apt-get install --no-install-recommends --no-install-suggests -y procps \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
|
||||
###
|
||||
### Configure
|
||||
###
|
||||
RUN set -x \
|
||||
&& rm -rf /usr/local/etc/php-fpm.d \
|
||||
&& mkdir -p /usr/local/etc/php-fpm.d
|
||||
|
||||
|
||||
###
|
||||
### Copy files
|
||||
###
|
||||
|
||||
@@ -5,6 +5,6 @@
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ item.dst }}"
|
||||
force: True
|
||||
mode: 0664
|
||||
mode: 0644
|
||||
with_items:
|
||||
- "{{ template_files }}"
|
||||
|
||||
@@ -19,9 +19,7 @@ FLAVOUR="${3}"
|
||||
# Tests
|
||||
############################################################
|
||||
|
||||
###
|
||||
### Test Nginx with PHP-FPM
|
||||
###
|
||||
|
||||
WWW_PORT="81"
|
||||
DOC_ROOT_HOST="$( mktemp -d )"
|
||||
DOC_ROOT_CONT="/var/www/default"
|
||||
@@ -69,7 +67,37 @@ ndid="$( docker_run "${CONTAINER}" "-v ${DOC_ROOT_HOST}:${DOC_ROOT_CONT} -v ${CO
|
||||
# Wait for both containers to be up and running
|
||||
run "sleep 10"
|
||||
|
||||
# Check PHP connectivity
|
||||
|
||||
###
|
||||
### Check correct PHP-FPM user
|
||||
###
|
||||
if ! docker_exec "${did}" "ps aux | grep 'php-fpm: pool' | grep -v grep | awk '{ print \$1 }' | head -1 | grep devilbox"; then
|
||||
docker_exec "${did}" "ps aux"
|
||||
|
||||
# Shutdown
|
||||
docker_stop "${ndid}" || true
|
||||
docker_stop "${did}" || true
|
||||
rm -rf "${DOC_ROOT_HOST}"
|
||||
rm -rf "${CONFIG_HOST}"
|
||||
echo "Failed"
|
||||
exit 1
|
||||
fi
|
||||
if ! docker_exec "${did}" "ps aux | grep 'php-fpm: pool' | grep -v grep | awk '{ print \$1 }' | tail -1 | grep devilbox"; then
|
||||
docker_exec "${did}" "ps aux"
|
||||
|
||||
# Shutdown
|
||||
docker_stop "${ndid}" || true
|
||||
docker_stop "${did}" || true
|
||||
rm -rf "${DOC_ROOT_HOST}"
|
||||
rm -rf "${CONFIG_HOST}"
|
||||
echo "Failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### Test Nginx with PHP-FPM
|
||||
###
|
||||
if ! run "curl -q -4 http://127.0.0.1:${WWW_PORT}/index.php 2>&1 | grep '${FINDME}'"; then
|
||||
|
||||
# Info
|
||||
@@ -102,7 +130,10 @@ if ! run "curl -q -4 http://127.0.0.1:${WWW_PORT}/index.php 2>&1 | grep '${FINDM
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Cleanup
|
||||
|
||||
###
|
||||
### Clean-up
|
||||
###
|
||||
docker_stop "${did}"
|
||||
docker_stop "${ndid}"
|
||||
rm -rf "${DOC_ROOT_HOST}"
|
||||
|
||||
Reference in New Issue
Block a user