Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 39 additions & 23 deletions assets/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,43 +16,59 @@ then
echo " |___/ "
echo
echo "Image: $DOCKER_IMAGE"
echo "Build Date: `cat /etc/build-date`"
echo "Build Date: $(cat /etc/build-date)"
echo
fi

# Adjust PHP
if [[ -f /usr/bin/php ]]
then
# Getting PHP INI Paths
PHPINI=`php -i | grep "Loaded Configuration File" | awk -F" => " '{print $2}'`
PHPMODULES=`php -i | grep "Scan this dir" | awk -F" => " '{print $2}'`
PHPMODULES=$(php -i | grep "Scan this dir" | awk -F" => " '{print $2}')
PHPCUSTOM=/etc/php/conf.d

# Disable modules
for VAR in `printenv | grep DISABLEMODULE | grep -E '(true|yes|1)' | cut -d= -f1 | cut -d_ -f2- | awk '{print tolower($0)}'`
do
if [[ -f "$PHPMODULES/*$VAR.ini" ]]
# Errors are always shown and stop the container; VERBOSE only shows the modules disabled.
# A module already disabled (e.g. after a restart) is not an error.
MODULE_OUTPUT=/dev/null
${VERBOSE_MODE} && MODULE_OUTPUT=/dev/stdout

# Keep only these modules (and the ones they require): PHP_ENABLED_MODULES="pdo_mysql,mbstring"
read -r -a ENABLED_MODULES <<< "${PHP_ENABLED_MODULES//,/ }"
if [[ ${#ENABLED_MODULES[@]} -gt 0 ]]
then
if ! /usr/local/bin/php-disable-module --all-except "${ENABLED_MODULES[@]}" > "$MODULE_OUTPUT"
then
${VERBOSE_MODE} && echo "Disabling Module $VAR ..."
rm "$PHPMODULES/*$VAR.ini"
elif [[ -f "$PHPMODULES/$VAR.ini" ]]
echo "PHP_ENABLED_MODULES=\"$PHP_ENABLED_MODULES\" failed (see above), stopping the container." >&2
exit 1
fi
fi

# Disable modules (and the ones that require them): PHP_DISABLE_MODULES="yaml,memcached"
read -r -a DISABLE_MODULES <<< "${PHP_DISABLE_MODULES//,/ }"
if [[ ${#DISABLE_MODULES[@]} -gt 0 ]]
then
if ! /usr/local/bin/php-disable-module "${DISABLE_MODULES[@]}" > "$MODULE_OUTPUT"
then
${VERBOSE_MODE} && echo "Disabling Module $VAR ..."
rm "$PHPMODULES/$VAR.ini"
else
${VERBOSE_MODE} && echo "Module not found $VAR"
echo "PHP_DISABLE_MODULES=\"$PHP_DISABLE_MODULES\" failed (see above), stopping the container." >&2
exit 1
fi
done
${VERBOSE_MODE} && echo
fi

# List available modules
if [[ "$VERBOSE" == "true" ]]
# Deprecated: DISABLEMODULE_<module>=true, will be removed in a future release. It does not stop
# the container on an error, as it did not before.
mapfile -t DEPRECATED_MODULES < <(printenv | grep -E '^DISABLEMODULE_[^=]+=(true|yes|1)$' | cut -d= -f1 | cut -d_ -f2- | awk '{print tolower($0)}')
if [[ ${#DEPRECATED_MODULES[@]} -gt 0 ]]
then
echo "DISABLEMODULE_<module> is deprecated, use PHP_DISABLE_MODULES=\"$(IFS=,; echo "${DEPRECATED_MODULES[*]}")\"" >&2
/usr/local/bin/php-disable-module "${DEPRECATED_MODULES[@]}" > "$MODULE_OUTPUT"
fi

# List the enabled modules
if ${VERBOSE_MODE}
then
echo
echo "Available Modules:"
for VAR in `ls $PHPMODULES/ | sort`
do
echo $VAR | awk -F"." '{printf $1; printf " "}'
done
/usr/local/bin/php-disable-module --list | tr '\n' ' '
echo
fi

Expand All @@ -63,7 +79,7 @@ then
fi

# Copy Custom Config
cp $PHPCUSTOM/*.ini $PHPMODULES/ 2>/dev/null || :
cp "$PHPCUSTOM"/*.ini "$PHPMODULES"/ 2>/dev/null || :
fi

exec "$@"
21 changes: 18 additions & 3 deletions assets/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,27 @@ <h2 class="text-3xl font-bold tracking-tight sm:text-4xl">Environment Configurat
</div>

<div class="rounded-xl border border-slate-200 bg-white shadow p-6">
<div class="font-semibold font-mono text-base mb-3">DISABLEMODULE_[name]</div>
<div class="font-semibold font-mono text-base mb-3">PHP_DISABLE_MODULES</div>
<div class="space-y-2">
<p class="text-slate-600">Disable specific PHP modules at runtime to optimize performance.</p>
<p class="text-slate-600">Comma separated list of PHP modules to disable at runtime to optimize performance.</p>
<p class="text-sm"><span class="font-medium">Default:</span> <span class="text-slate-600">All modules enabled</span></p>
<div class="relative code-block mt-3">
<pre class="overflow-x-auto rounded-xl border border-slate-200 bg-slate-100 p-4 pr-12 font-mono text-sm"><code>docker run -e DISABLEMODULE_DOM=true -e DISABLEMODULE_XSL=true @@DOCKER_IMAGE@@</code></pre>
<pre class="overflow-x-auto rounded-xl border border-slate-200 bg-slate-100 p-4 pr-12 font-mono text-sm"><code>docker run -e PHP_DISABLE_MODULES="dom,xsl" @@DOCKER_IMAGE@@</code></pre>
<button onclick="copyCode(this)" class="copy-btn absolute right-2 top-2 rounded-md border border-slate-200 bg-white p-2 text-slate-500 hover:text-slate-900" aria-label="Copy to clipboard">
<svg class="copy-icon h-4 w-4" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>
<svg class="check-icon h-4 w-4 text-green-600" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="20 6 9 17 4 12"/></svg>
</button>
</div>
</div>
</div>

<div class="rounded-xl border border-slate-200 bg-white shadow p-6">
<div class="font-semibold font-mono text-base mb-3">PHP_ENABLED_MODULES</div>
<div class="space-y-2">
<p class="text-slate-600">Comma separated list of PHP modules to keep enabled at runtime; all the others are disabled. The modules they require are kept too.</p>
<p class="text-sm"><span class="font-medium">Default:</span> <span class="text-slate-600">All modules enabled</span></p>
<div class="relative code-block mt-3">
<pre class="overflow-x-auto rounded-xl border border-slate-200 bg-slate-100 p-4 pr-12 font-mono text-sm"><code>docker run -e PHP_ENABLED_MODULES="pdo_mysql,mbstring" @@DOCKER_IMAGE@@</code></pre>
<button onclick="copyCode(this)" class="copy-btn absolute right-2 top-2 rounded-md border border-slate-200 bg-white p-2 text-slate-500 hover:text-slate-900" aria-label="Copy to clipboard">
<svg class="copy-icon h-4 w-4" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>
<svg class="check-icon h-4 w-4 text-green-600" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="20 6 9 17 4 12"/></svg>
Expand Down
25 changes: 20 additions & 5 deletions assets/script/install-sqlsvr.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env bash

#
# https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver15&tabs=alpine18-install%2Calpine17-install%2Cdebian8-install%2Credhat7-13-install%2Crhel7-offline#alpine-linux
Expand All @@ -8,7 +9,7 @@ set -x

case $(uname -m) in
x86_64) ARCH="amd64" ;;
arm64) ARCH="arm64" ;;
aarch64|arm64) ARCH="arm64" ;;
*) ARCH="unsupported" ;;
esac
if [[ "unsupported" == "$ARCH" ]];
Expand All @@ -28,10 +29,24 @@ wget ${BASE_URL}/msodbcsql${VERSION_ODBC}.apk
wget ${BASE_URL}/mssql-tools${VERSION_TOOLS}.apk
yes | apk add --allow-untrusted msodbcsql${VERSION_ODBC}.apk
yes | apk add --allow-untrusted mssql-tools${VERSION_TOOLS}.apk
apk add --no-cache --virtual .phpize-deps ${PHP_VARIANT}-dev build-base unixodbc-dev
pecl install pdo_sqlsrv
echo extension=pdo_sqlsrv.so > /etc/${PHP_VARIANT}/conf.d/30_sqlsvr.ini
apk del .phpize-deps
# The extension is enabled only when it builds, so a failed build leaves no .ini behind.
# pdo_sqlsrv does not build on every PHP version (e.g. 8.6, until Microsoft publishes a
# compatible release): the extension is then skipped, and the ODBC driver stays installed.
# Images with PIE (PHP 8.3+) use it; the older ones keep PECL.
if command -v pie-install >/dev/null;
then
pie-install --deps unixodbc --build-deps unixodbc-dev microsoft/pdo_sqlsrv
STATUS=$?
else
apk add --no-cache --virtual .phpize-deps ${PHP_VARIANT}-dev build-base unixodbc-dev
pecl install pdo_sqlsrv && echo extension=pdo_sqlsrv.so > /etc/${PHP_VARIANT}/conf.d/30_sqlsvr.ini
STATUS=$?
apk del .phpize-deps
fi
if [[ $STATUS -ne 0 ]];
then
echo "SKIPPED: pdo_sqlsrv does not build on PHP ${PHP_VERSION} (see the build log above). The Microsoft ODBC driver is installed, the PHP extension is not." >&2
fi
rm -f msodbcsql${VERSION_ODBC}.apk
rm -f mssql-tools${VERSION_TOOLS}.apk
rm -rf pear
Loading
Loading