Use precompiled PHP extensions for docker container

This should hopefully reduce the build times for cross compiled images, as we dont have to build extensions from source there.
This commit is contained in:
Jan Böhmer 2023-02-05 18:58:57 +01:00
parent ba5ae35809
commit 66e566b99a
4 changed files with 127 additions and 13 deletions

View file

@ -0,0 +1,43 @@
#!/bin/bash
### Taken from here: https://github.com/docker-library/php/blob/master/apache2-foreground
set -e
# Note: we don't just use "apache2ctl" here because it itself is just a shell-script wrapper around apache2 which provides extra functionality like "apache2ctl start" for launching apache2 in the background.
# (also, when run as "apache2ctl <apache args>", it does not use "exec", which leaves an undesirable resident shell process)
: "${APACHE_CONFDIR:=/etc/apache2}"
: "${APACHE_ENVVARS:=$APACHE_CONFDIR/envvars}"
if test -f "$APACHE_ENVVARS"; then
. "$APACHE_ENVVARS"
fi
# Apache gets grumpy about PID files pre-existing
: "${APACHE_RUN_DIR:=/var/run/apache2}"
: "${APACHE_PID_FILE:=$APACHE_RUN_DIR/apache2.pid}"
rm -f "$APACHE_PID_FILE"
# create missing directories
# (especially APACHE_RUN_DIR, APACHE_LOCK_DIR, and APACHE_LOG_DIR)
for e in "${!APACHE_@}"; do
if [[ "$e" == *_DIR ]] && [[ "${!e}" == /* ]]; then
# handle "/var/lock" being a symlink to "/run/lock", but "/run/lock" not existing beforehand, so "/var/lock/something" fails to mkdir
# mkdir: cannot create directory '/var/lock': File exists
dir="${!e}"
while [ "$dir" != "$(dirname "$dir")" ]; do
dir="$(dirname "$dir")"
if [ -d "$dir" ]; then
break
fi
absDir="$(readlink -f "$dir" 2>/dev/null || :)"
if [ -n "$absDir" ]; then
mkdir -p "$absDir"
fi
done
mkdir -p "${!e}"
fi
done
exec apache2 -DFOREGROUND "$@"

View file

@ -39,5 +39,10 @@ if [ -d /var/www/html/var/db ]; then
fi
fi
# first arg is `-f` or `--some-option` (taken from https://github.com/docker-library/php/blob/master/8.2/bullseye/apache/docker-php-entrypoint)
if [ "${1#-}" != "$1" ]; then
set -- apache2-foreground "$@"
fi
# Pass to the original entrypoint
exec "$@"

View file

@ -24,6 +24,16 @@
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# Pass the configuration from the docker env to the PHP environment (here you should list all .env options)
PassEnv APP_ENV APP_DEBUG APP_SECRET
PassEnv DATABASE_URL
PassEnv DEFAULT_LANG DEFAULT_TIMEZONE BASE_CURRENCY INSTANCE_NAME ALLOW_ATTACHMENT_DOWNLOADS USE_GRAVATAR
PassEnv MAILER_DSN ALLOW_EMAIL_PW_RESET EMAIL_SENDER_EMAIL EMAIL_SENDER_NAME
PassEnv HISTORY_SAVE_CHANGED_FIELDS HISTORY_SAVE_CHANGED_DATA HISTORY_SAVE_REMOVED_DATA
PassEnv ERROR_PAGE_ADMIN_EMAIL ERROR_PAGE_SHOW_HELP
PassEnv DEMO_MODE NO_URL_REWRITE_AVAILABLE FIXER_API_KEY BANNER
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the