Skip to content
Snippets Groups Projects
Commit d8f786d9 authored by Andrey Postnikov's avatar Andrey Postnikov Committed by Andrey Postnikov
Browse files

Issue #3443853 by andypost: Provide PHP 8.4-ubuntu-apache image

(cherry picked from commit 90641d5c)
parent 8052bc0e
No related branches found
No related tags found
No related merge requests found
Pipeline #216100 passed
Showing with 1072 additions and 0 deletions
######
# Base
######
ARG THE_BASE_IMAGE=ubuntu:noble
ARG PHPIZE_DEPS="autoconf file g++ gcc make pkg-config re2c"
ARG PHP_CFLAGS="-O2 -g"
FROM ${THE_BASE_IMAGE} as builder
ENV DRUPALCI=TRUE TERM=xterm DEBIAN_FRONTEND=noninteractive
#########
# Php build
######
# PHP Version
ENV PHP_VERSION 8.4.0alpha1
ENV PHP_URL="https://downloads.php.net/~saki/php-${PHP_VERSION}.tar.xz"
ENV PHP_SHA256_HASH="65903a7add51350540b567f8cd2d964ac11366bf33e1b287489765feac45278e php.tar.xz"
ARG PHPIZE_DEPS
ARG PHP_CFLAGS
ENV PHP_CFLAGS="$PHP_CFLAGS"
ENV PHP_CPPFLAGS="$PHP_CFLAGS"
ENV PHP_LDFLAGS=""
RUN set -eux &&\
echo 'APT::Install-Recommends "0";' >/etc/apt/apt.conf.d/99norecommends &&\
apt-get update && apt-get install -qy --no-install-recommends \
ca-certificates curl apt-utils &&\
\
mkdir -p /usr/src &&\
cd /usr/src &&\
\
curl -LS -o php.tar.xz "$PHP_URL" &&\
\
echo $PHP_SHA256_HASH | sha256sum -c &&\
\
buildDeps=" \
apache2-dev apache2 \
libcurl4-openssl-dev \
libedit-dev \
libfreetype-dev \
libicu-dev \
libjpeg-turbo8-dev \
libonig-dev \
zlib1g-dev \
libpng-dev \
libwebp-dev \
libavif-dev \
libsqlite3-dev \
libpq-dev \
libssl-dev \
libtidy-dev \
libxml2-dev \
libxslt1-dev \
libyaml-dev \
libzip-dev \
libncurses-dev \
" &&\
apt-get install -qy --no-install-recommends $PHPIZE_DEPS $buildDeps bison &&\
rm -rf /var/lib/apt/lists/*
RUN set -xe &&\
buildDir="/usr/src/php" &&\
mkdir -p /usr/local/etc/php/conf.d &&\
\
mkdir "$buildDir" &&\
tar -Jxf /usr/src/php.tar.xz -C "$buildDir" --strip-components=1 &&\
cd "$buildDir" &&\
./buildconf &&\
CFLAGS="$PHP_CFLAGS" \
CPPFLAGS="$PHP_CPPFLAGS" \
LDFLAGS="$PHP_LDFLAGS" \
./configure \
--with-config-file-path=/usr/local/etc/php \
--with-config-file-scan-dir=/usr/local/etc/php/conf.d \
--enable-ftp \
--enable-mbstring \
--enable-mysqlnd \
--with-curl \
--with-libedit \
--with-zlib \
--with-openssl \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-pdo-sqlite \
--with-pdo-pgsql \
--with-readline \
--with-freetype \
--with-jpeg \
--with-xsl \
--with-tidy \
--with-gettext=shared \
--enable-gd \
--with-webp \
--with-avif \
--with-pear \
--enable-sockets \
--enable-exif \
--with-zip \
--enable-soap \
--enable-sysvsem \
--enable-sysvshm \
--enable-shmop \
--enable-pcntl \
--enable-bcmath \
--enable-xmlreader \
--enable-intl \
--enable-opcache \
--with-apxs2 \
--disable-cgi \
--disable-phpdbg \
&&\
make -j "$(nproc)" &&\
make install &&\
cd / && rm -fr "$buildDir"
# install pecl extensions for apcu, pcov, xdebug, and yaml
RUN pecl channel-update pecl.php.net &&\
pecl install APCu-5.1.23 yaml-2.2.3 \
&&\
# stript .debug files out of executables
echo '\
for file in "$@"; do \
objcopy --only-keep-debug "$file" "$file".debug; \
strip --strip-debug --strip-unneeded "$file"; \
objcopy --add-gnu-debuglink="$file".debug "$file"; \
done' > /strip.sh; \
sh strip.sh \
/usr/lib/apache2/modules/libphp.so \
/usr/local/bin/php \
$(php -r 'echo ini_get("extension_dir");')/*.so
COPY ./conf/php/php.ini /usr/local/etc/php/php.ini
COPY ./conf/php/php-cli.ini /usr/local/etc/php/php-cli.ini
COPY ./docker-php-* /usr/local/bin/
#########
# Php Setup
######
FROM ${THE_BASE_IMAGE}
ARG DEBIAN_FRONTEND=noninteractive
ENV DRUPALCI=TRUE TERM=xterm
COPY --from=builder /usr/local /usr/local
COPY --from=builder /usr/lib/apache2/modules/libphp.so /usr/lib/apache2/modules/libphp.so.debug /usr/lib/apache2/modules/
COPY --from=builder /etc/apache2/mods-enabled/php.load /etc/apache2/mods-enabled/php.load
COPY --from=builder /etc/apache2/mods-available/php.load /etc/apache2/mods-available/php.load
RUN set -xe &&\
echo 'APT::Install-Recommends "0";' >/etc/apt/apt.conf.d/99norecommends ;\
apt-get update &&\
buildDeps=" \
libedit2 \
libfreetype6 \
libicu74 \
libjpeg-turbo8 \
libonig5 \
libpng16-16 \
zlib1g \
libwebp7 \
libavif16 \
libaom3 \
libsqlite3-0 \
libpq5 \
libtidy5deb1 \
libyaml-0-2 \
libxml2 \
libxslt1.1 \
libzip4 \
libncurses6 \
" &&\
runDeps=" \
apache2 \
bzip2 \
curl ca-certificates gnupg2 \
default-mysql-client postgresql-client sudo git sqlite3 \
patch \
rsync \
unzip \
xz-utils \
" &&\
apt-get install -qy --no-install-recommends $buildDeps $runDeps &&\
rm -rf /var/lib/apt/lists/*
# Install Composer, Drush
RUN curl -sSLo /tmp/composer-setup.php https://getcomposer.org/installer &&\
curl -sSLo /tmp/composer-setup.sig https://composer.github.io/installer.sig &&\
php -r "if (hash('SHA384', file_get_contents('/tmp/composer-setup.php')) !== trim(file_get_contents('/tmp/composer-setup.sig'))) { unlink('/tmp/composer-setup.php'); echo 'Invalid installer' . PHP_EOL; exit(1); }" &&\
php /tmp/composer-setup.php --filename composer --install-dir /usr/local/bin &&\
curl -sSLo /usr/local/bin/drush https://github.com/drush-ops/drush/releases/download/8.3.5/drush.phar &&\
chmod +x /usr/local/bin/drush &&\
/usr/local/bin/drush --version
# Install nodejs and yarn
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/trusted.gpg.d/nodesource.gpg &&\
echo 'deb [signed-by=/etc/apt/trusted.gpg.d/nodesource.gpg] https://deb.nodesource.com/node_18.x nodistro main' | tee /etc/apt/sources.list.d/nodesource.list &&\
curl -sSLo /etc/apt/trusted.gpg.d/yarn.gpg.asc https://dl.yarnpkg.com/debian/pubkey.gpg &&\
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list &&\
apt-get update &&\
apt-get install -qy --no-install-recommends nodejs yarn &&\
rm -rf /var/lib/apt/lists/*
# Install phantomjs, supervisor
RUN _file=phantomjs-2.1.1-linux-x86_64 &&\
curl -sSLo /$_file.tar.bz2 https://bitbucket.org/ariya/phantomjs/downloads/$_file.tar.bz2 &&\
tar -jxf /$_file.tar.bz2 -C / &&\
mv /$_file/bin/phantomjs /usr/bin/phantomjs &&\
rm -f /$_file.tar.bz2 &&\
rm -rf /$_file &&\
chmod 755 /usr/bin/phantomjs &&\
apt-get update &&\
apt-get install -qy --no-install-recommends supervisor fontconfig &&\
rm -rf /var/lib/apt/lists/*
COPY ./conf/supervisor-phantomjs.conf /etc/supervisor/conf.d/phantomjs.conf
######
# Apache Setup
######
RUN set -ex \
\
&& sed -ri 's/^export ([^=]+)=(.*)$/: ${\1:=\2}\nexport \1/' /etc/apache2/envvars \
&& sed -i 's/Require local/#Require local/' /etc/apache2/mods-available/status.conf \
\
&& . /etc/apache2/envvars \
&& echo "ServerName localhost" >> /etc/apache2/apache2.conf \
&& for dir in \
"$APACHE_LOCK_DIR" \
"$APACHE_RUN_DIR" \
"$APACHE_LOG_DIR" \
/var/www/html \
/var/www/apc \
; do \
rm -rvf "$dir" \
&& mkdir -p "$dir" \
&& chown -R "$APACHE_RUN_USER:$APACHE_RUN_GROUP" "$dir"; \
done
COPY ./conf/apache2/vhost.conf /etc/apache2/sites-available/drupal.conf
COPY ./apache2-foreground /usr/local/bin/
# Apache + PHP requires preforking Apache for best results
RUN a2dismod mpm_event && a2enmod mpm_prefork &&\
a2enmod expires headers rewrite &&\
\
# PHP files should be handled by PHP, and should be preferred over any other file type
{ \
echo '<FilesMatch \.php$>'; \
echo '\tSetHandler application/x-httpd-php'; \
echo '</FilesMatch>'; \
echo; \
echo 'DirectoryIndex disabled'; \
echo 'DirectoryIndex index.php index.html'; \
echo; \
echo '<Directory /var/www/>'; \
echo '\tOptions -Indexes'; \
echo '\tAllowOverride All'; \
echo '</Directory>'; \
} | tee /etc/apache2/conf-available/docker-php.conf &&\
a2enconf docker-php &&\
a2dissite 000-default.conf &&\
a2ensite drupal
ARG PHPIZE_DEPS
ENV PHPIZE_DEPS=$PHPIZE_DEPS
ARG PHP_CFLAGS
ENV PHP_CFLAGS="$PHP_CFLAGS"
ENV PHP_CPPFLAGS="$PHP_CFLAGS"
ENV PHP_LDFLAGS=""
ENTRYPOINT ["docker-php-entrypoint"]
WORKDIR /var/www/html
EXPOSE 80
CMD ["apache2-foreground"]
#!/bin/bash
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_PID_FILE:=${APACHE_RUN_DIR:=/var/run/apache2}/apache2.pid}"
rm -f "$APACHE_PID_FILE"
exec apache2 -DFOREGROUND "$@"
<VirtualHost *:80>
DocumentRoot /var/www/html
RewriteEngine On
Alias "/apc" "/var/www/apc"
Alias "/server-status" "/var/www/apc"
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order Allow,Deny
Allow from All
</Directory>
ErrorLog /var/log/apache2/test.apache.error.log
ServerSignature Off
CustomLog /var/log/apache2/test.apache.access.log combined
</VirtualHost>
[PHP]
engine = On
short_open_tag = Off
asp_tags = Off
precision = 14
output_buffering = 4096
zlib.output_compression = Off
implicit_flush = Off
unserialize_callback_func =
serialize_precision = -1
disable_functions =
disable_classes =
zend.enable_gc = On
expose_php = On
max_execution_time = 300
max_input_time = 60
memory_limit = -1
error_reporting = E_ALL & ~E_DEPRECATED
display_errors = Off
display_startup_errors = Off
log_errors = On
log_errors_max_len = 1024
ignore_repeated_errors = Off
ignore_repeated_source = Off
report_memleaks = On
track_errors = Off
html_errors = Off
variables_order = "GPCS"
request_order = "GP"
register_argc_argv = Off
auto_globals_jit = On
post_max_size = 8M
auto_prepend_file =
auto_append_file =
default_mimetype = "text/html"
doc_root =
user_dir =
enable_dl = Off
file_uploads = On
upload_max_filesize = 8M
max_file_uploads = 20
allow_url_fopen = On
allow_url_include = Off
default_socket_timeout = 60
assert.exception = 1
[CLI Server]
cli_server.color = On
[Pdo_mysql]
pdo_mysql.cache_size = 2000
pdo_mysql.default_socket=
[Phar]
[Syslog]
define_syslog_variables = Off
[mail function]
SMTP = localhost
smtp_port = 25
mail.add_x_header = On
[SQL]
sql.safe_mode = Off
[ODBC]
odbc.allow_persistent = On
odbc.check_persistent = On
odbc.max_persistent = -1
odbc.max_links = -1
odbc.defaultlrl = 4096
odbc.defaultbinmode = 1
[Interbase]
ibase.allow_persistent = 1
ibase.max_persistent = -1
ibase.max_links = -1
ibase.timestampformat = "%Y-%m-%d %H:%M:%S"
ibase.dateformat = "%Y-%m-%d"
ibase.timeformat = "%H:%M:%S"
[MySQL]
mysql.allow_local_infile = On
mysql.allow_persistent = On
mysql.cache_size = 2000
mysql.max_persistent = -1
mysql.max_links = -1
mysql.default_port =
mysql.default_socket =
mysql.default_host =
mysql.default_user =
mysql.default_password =
mysql.connect_timeout = 60
mysql.trace_mode = Off
[MySQLi]
mysqli.max_persistent = -1
mysqli.allow_persistent = On
mysqli.max_links = -1
mysqli.cache_size = 2000
mysqli.default_port = 3306
mysqli.default_socket =
mysqli.default_host =
mysqli.default_user =
mysqli.default_pw =
mysqli.reconnect = Off
[mysqlnd]
mysqlnd.collect_statistics = On
mysqlnd.collect_memory_statistics = Off
[OCI8]
[PostgreSQL]
pgsql.allow_persistent = On
pgsql.auto_reset_persistent = Off
pgsql.max_persistent = -1
pgsql.max_links = -1
pgsql.ignore_notice = 0
pgsql.log_notice = 0
[Sybase-CT]
sybct.allow_persistent = On
sybct.max_persistent = -1
sybct.max_links = -1
sybct.min_server_severity = 10
sybct.min_client_severity = 10
[bcmath]
bcmath.scale = 0
[browscap]
[Session]
session.save_handler = files
session.save_path = "/tmp"
session.use_strict_mode = 0
session.use_cookies = 1
session.use_only_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.cookie_httponly =
session.serialize_handler = php
session.gc_probability = 1
session.gc_divisor = 1000
session.gc_maxlifetime = 1440
session.referer_check =
session.entropy_length = 0
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.hash_function = 0
session.hash_bits_per_character = 5
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
[MSSQL]
mssql.allow_persistent = On
mssql.max_persistent = -1
mssql.max_links = -1
mssql.min_error_severity = 10
mssql.min_message_severity = 10
mssql.compatibility_mode = Off
mssql.secure_connection = Off
[Tidy]
tidy.clean_output = Off
[soap]
soap.wsdl_cache_enabled=1
soap.wsdl_cache_dir="/tmp"
soap.wsdl_cache_ttl=86400
soap.wsdl_cache_limit = 5
[ldap]
ldap.max_links = -1
[gettext]
extension="gettext.so"
[opcache]
zend_extension="opcache.so"
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=1000
opcache.interned_strings_buffer=4
opcache.max_accelerated_files=100000
opcache.max_wasted_percentage=5
opcache.revalidate_freq=0
[apcu]
extension="apcu.so"
apc.enabled = 1
apc.shm_size = 3000M
apc.entries_hint = 500000
apc.enable_cli = 1
apc.mmap_file_mask = /tmp/apc.XXXXXX
apc.rfc1867 = 1
apc.include_once_override = 0
[xdebug]
html_errors=on
xdebug.remote_autostart=on
xdebug.remote_enable=on
xdebug.remote_log="/tmp/xdebug.log"
xdebug.default_enable=1
xdebug.idekey="phpcontainer"
xdebug.remote_host="172.17.42.1"
xdebug.remote_port="9000"
[Date]
date.timezone = UTC
[yaml]
extension=yaml
[PHP]
engine = On
short_open_tag = Off
asp_tags = Off
precision = 14
output_buffering = 4096
zlib.output_compression = Off
implicit_flush = Off
unserialize_callback_func =
serialize_precision = -1
disable_functions =
disable_classes =
zend.enable_gc = On
expose_php = On
max_execution_time = 300
max_input_time = 60
memory_limit = 320M
error_reporting = E_ALL & ~E_DEPRECATED
display_errors = Off
display_startup_errors = Off
log_errors = On
log_errors_max_len = 1024
ignore_repeated_errors = Off
ignore_repeated_source = Off
report_memleaks = On
track_errors = Off
html_errors = Off
variables_order = "GPCS"
request_order = "GP"
register_argc_argv = Off
auto_globals_jit = On
post_max_size = 8M
auto_prepend_file =
auto_append_file =
default_mimetype = "text/html"
doc_root =
user_dir =
enable_dl = Off
file_uploads = On
upload_max_filesize = 8M
max_file_uploads = 20
allow_url_fopen = On
allow_url_include = Off
default_socket_timeout = 60
assert.exception = 1
[CLI Server]
cli_server.color = On
[Pdo_mysql]
pdo_mysql.cache_size = 2000
pdo_mysql.default_socket=
[Phar]
[Syslog]
define_syslog_variables = Off
[mail function]
SMTP = localhost
smtp_port = 25
mail.add_x_header = On
[SQL]
sql.safe_mode = Off
[ODBC]
odbc.allow_persistent = On
odbc.check_persistent = On
odbc.max_persistent = -1
odbc.max_links = -1
odbc.defaultlrl = 4096
odbc.defaultbinmode = 1
[Interbase]
ibase.allow_persistent = 1
ibase.max_persistent = -1
ibase.max_links = -1
ibase.timestampformat = "%Y-%m-%d %H:%M:%S"
ibase.dateformat = "%Y-%m-%d"
ibase.timeformat = "%H:%M:%S"
[MySQL]
mysql.allow_local_infile = On
mysql.allow_persistent = On
mysql.cache_size = 2000
mysql.max_persistent = -1
mysql.max_links = -1
mysql.default_port =
mysql.default_socket =
mysql.default_host =
mysql.default_user =
mysql.default_password =
mysql.connect_timeout = 60
mysql.trace_mode = Off
[MySQLi]
mysqli.max_persistent = -1
mysqli.allow_persistent = On
mysqli.max_links = -1
mysqli.cache_size = 2000
mysqli.default_port = 3306
mysqli.default_socket =
mysqli.default_host =
mysqli.default_user =
mysqli.default_pw =
mysqli.reconnect = Off
[mysqlnd]
mysqlnd.collect_statistics = On
mysqlnd.collect_memory_statistics = Off
[OCI8]
[PostgreSQL]
pgsql.allow_persistent = On
pgsql.auto_reset_persistent = Off
pgsql.max_persistent = -1
pgsql.max_links = -1
pgsql.ignore_notice = 0
pgsql.log_notice = 0
[Sybase-CT]
sybct.allow_persistent = On
sybct.max_persistent = -1
sybct.max_links = -1
sybct.min_server_severity = 10
sybct.min_client_severity = 10
[bcmath]
bcmath.scale = 0
[browscap]
[Session]
session.save_handler = files
session.save_path = "/tmp"
session.use_strict_mode = 0
session.use_cookies = 1
session.use_only_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.cookie_httponly =
session.serialize_handler = php
session.gc_probability = 1
session.gc_divisor = 1000
session.gc_maxlifetime = 1440
session.referer_check =
session.entropy_length = 0
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.hash_function = 0
session.hash_bits_per_character = 5
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
[MSSQL]
mssql.allow_persistent = On
mssql.max_persistent = -1
mssql.max_links = -1
mssql.min_error_severity = 10
mssql.min_message_severity = 10
mssql.compatibility_mode = Off
mssql.secure_connection = Off
[Tidy]
tidy.clean_output = Off
[soap]
soap.wsdl_cache_enabled=1
soap.wsdl_cache_dir="/tmp"
soap.wsdl_cache_ttl=86400
soap.wsdl_cache_limit = 5
[ldap]
ldap.max_links = -1
[gettext]
extension="gettext.so"
[opcache]
zend_extension="opcache.so"
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=1000
opcache.interned_strings_buffer=4
opcache.max_accelerated_files=100000
opcache.max_wasted_percentage=5
opcache.revalidate_freq=0
[apcu]
extension="apcu.so"
apc.enabled = 1
apc.shm_size = 3000M
apc.entries_hint = 500000
apc.enable_cli = 1
apc.mmap_file_mask = /tmp/apc.XXXXXX
apc.rfc1867 = 1
apc.include_once_override = 0
[xdebug]
html_errors=on
xdebug.remote_autostart=on
xdebug.remote_enable=on
xdebug.remote_log="/tmp/xdebug.log"
xdebug.default_enable=1
xdebug.idekey="phpcontainer"
xdebug.remote_host="172.17.42.1"
xdebug.remote_port="9000"
[Date]
date.timezone = UTC
[yaml]
extension=yaml
[program:phantomjs]
command=/usr/bin/phantomjs --ssl-protocol=any --debug=true --ignore-ssl-errors=true /var/www/html/vendor/jcalderonzumba/gastonjs/src/Client/main.js 8510 1024 768
directory=/var/www/html
autostart=false
autorestart=true
startretries=5
stderr_logfile=/var/log/supervisor/phantomjs.err.log
stdout_logfile=/var/log/supervisor/phantomjs.out.log
user=www-data
#!/bin/sh
set -e
# first arg is -f or --some-option
if [ "${1#-}" != "$1" ]; then
set -- apache2-foreground "$@"
fi
/usr/bin/supervisord -c /etc/supervisor/supervisord.conf
exec "$@"
#!/bin/sh
set -e
# prefer user supplied CFLAGS, but default to our PHP_CFLAGS
: ${CFLAGS:=$PHP_CFLAGS}
: ${CPPFLAGS:=$PHP_CPPFLAGS}
: ${LDFLAGS:=$PHP_LDFLAGS}
export CFLAGS CPPFLAGS LDFLAGS
srcExists=
if [ -d /usr/src/php ]; then
srcExists=1
fi
docker-php-source extract
if [ -z "$srcExists" ]; then
touch /usr/src/php/.docker-delete-me
fi
cd /usr/src/php/ext
ext="$1"
if [ -z "$ext" ] || [ ! -d "$ext" ]; then
echo >&2 "usage: $0 ext-name [configure flags]"
echo >&2 " ie: $0 gd --with-jpeg-dir=/usr/local/something"
echo >&2
echo >&2 'Possible values for ext-name:'
find /usr/src/php/ext \
-mindepth 2 \
-maxdepth 2 \
-type f \
-name 'config.m4' \
| xargs -n1 dirname \
| xargs -n1 basename \
| sort \
| xargs
exit 1
fi
shift
pm='unknown'
if [ -e /lib/apk/db/installed ]; then
pm='apk'
fi
if [ "$pm" = 'apk' ]; then
if \
[ -n "$PHPIZE_DEPS" ] \
&& ! apk info --installed .phpize-deps > /dev/null \
&& ! apk info --installed .phpize-deps-configure > /dev/null \
; then
apk add --no-cache --virtual .phpize-deps-configure $PHPIZE_DEPS
fi
fi
set -x
cd "$ext"
phpize
./configure "$@"
#!/bin/sh
set -e
cd "$(php -r 'echo ini_get("extension_dir");')"
usage() {
echo "usage: $0 [options] module-name [module-name ...]"
echo " ie: $0 gd mysqli"
echo " $0 pdo pdo_mysql"
echo " $0 --ini-name 0-apc.ini apcu apc"
echo
echo 'Possible values for module-name:'
echo $(find -maxdepth 1 -type f -name '*.so' -exec basename '{}' ';' | sort)
}
opts="$(getopt -o 'h?' --long 'help,ini-name:' -- "$@" || { usage >&2 && false; })"
eval set -- "$opts"
iniName=
while true; do
flag="$1"
shift
case "$flag" in
--help|-h|'-?') usage && exit 0 ;;
--ini-name) iniName="$1" && shift ;;
--) break ;;
*)
{
echo "error: unknown flag: $flag"
usage
} >&2
exit 1
;;
esac
done
modules=
for module; do
if [ -z "$module" ]; then
continue
fi
if [ -f "$module.so" ] && ! [ -f "$module" ]; then
# allow ".so" to be optional
module="$module.so"
fi
if ! [ -f "$module" ]; then
echo >&2 "error: $(readlink -f "$module") does not exist"
echo >&2
usage >&2
exit 1
fi
modules="$modules $module"
done
if [ -z "$modules" ]; then
usage >&2
exit 1
fi
for module in $modules; do
if [ -z "$(php -dzend_extension="$module" -v 2>&1 >/dev/null)" ]; then
# https://wiki.php.net/internals/extensions#loading_zend_extensions
line="zend_extension=$(readlink -f "$module")"
else
line="extension=$module"
fi
ext="$(basename "$module")"
ext="${ext%.*}"
if php -r 'exit(extension_loaded("'"$ext"'") ? 0 : 1);'; then
# this isn't perfect, but it's better than nothing
# (for example, 'opcache.so' presents inside PHP as 'Zend OPcache', not 'opcache')
echo >&2
echo >&2 "warning: $ext ($module) is already loaded!"
echo >&2
continue
fi
ini="/usr/local/etc/php/conf.d/${iniName:-"docker-php-ext-$ext.ini"}"
if ! grep -q "$line" "$ini" 2>/dev/null; then
echo "$line" >> "$ini"
fi
done
#!/bin/sh
set -e
# prefer user supplied CFLAGS, but default to our PHP_CFLAGS
: ${CFLAGS:=$PHP_CFLAGS}
: ${CPPFLAGS:=$PHP_CPPFLAGS}
: ${LDFLAGS:=$PHP_LDFLAGS}
export CFLAGS CPPFLAGS LDFLAGS
srcExists=
if [ -d /usr/src/php ]; then
srcExists=1
fi
docker-php-source extract
if [ -z "$srcExists" ]; then
touch /usr/src/php/.docker-delete-me
fi
cd /usr/src/php/ext
usage() {
echo "usage: $0 [-jN] ext-name [ext-name ...]"
echo " ie: $0 gd mysqli"
echo " $0 pdo pdo_mysql"
echo " $0 -j5 gd mbstring mysqli pdo pdo_mysql shmop"
echo
echo 'if custom ./configure arguments are necessary, see docker-php-ext-configure'
echo
echo 'Possible values for ext-name:'
find . \
-mindepth 2 \
-maxdepth 2 \
-type f \
-name 'config.m4' \
| xargs -n1 dirname \
| xargs -n1 basename \
| sort \
| xargs
}
opts="$(getopt -o 'h?j:' --long 'help,jobs:' -- "$@" || { usage >&2 && false; })"
eval set -- "$opts"
j=1
while true; do
flag="$1"
shift
case "$flag" in
--help|-h|'-?') usage && exit 0 ;;
--jobs|-j) j="$1" && shift ;;
--) break ;;
*)
{
echo "error: unknown flag: $flag"
usage
} >&2
exit 1
;;
esac
done
exts=
for ext; do
if [ -z "$ext" ]; then
continue
fi
if [ ! -d "$ext" ]; then
echo >&2 "error: $PWD/$ext does not exist"
echo >&2
usage >&2
exit 1
fi
exts="$exts $ext"
done
if [ -z "$exts" ]; then
usage >&2
exit 1
fi
pm='unknown'
if [ -e /lib/apk/db/installed ]; then
pm='apk'
fi
apkDel=
if [ "$pm" = 'apk' ]; then
if [ -n "$PHPIZE_DEPS" ]; then
if apk info --installed .phpize-deps-configure > /dev/null; then
apkDel='.phpize-deps-configure'
elif ! apk info --installed .phpize-deps > /dev/null; then
apk add --no-cache --virtual .phpize-deps $PHPIZE_DEPS
apkDel='.phpize-deps'
fi
fi
fi
popDir="$PWD"
for ext in $exts; do
cd "$ext"
[ -e Makefile ] || docker-php-ext-configure "$ext"
make -j"$j"
make -j"$j" install
find modules \
-maxdepth 1 \
-name '*.so' \
-exec basename '{}' ';' \
| xargs -r docker-php-ext-enable
make -j"$j" clean
cd "$popDir"
done
if [ "$pm" = 'apk' ] && [ -n "$apkDel" ]; then
apk del $apkDel
fi
if [ -e /usr/src/php/.docker-delete-me ]; then
docker-php-source delete
fi
#!/bin/bash
set -e
usage() {
echo "usage: $0 [channel/]<package> ..."
echo " ie: $0 uploadprogress oauth-1.2.3"
}
if [ $# -eq 0 ]; then
usage >&2
exit 1
fi
pecl install "$@"
while [ $# -gt 0 ]; do
ext="$1"
ext=$(echo "$ext" | cut -d- -f1)
ext=$(echo "$ext" | cut -d\/ -f2)
shift
for module in $(find /usr/local/lib/php/extensions -name "$ext.so"); do
ini="/usr/local/etc/php/conf.d/docker-php-pecl-$ext.ini"
if grep -q zend_extension_entry "$module"; then
# https://wiki.php.net/internals/extensions#loading_zend_extensions
line="zend_extension=$(readlink -f "$module")"
else
line="extension=$(basename "$module")"
fi
if ! grep -q "$line" "$ini" 2>/dev/null; then
echo "$line" >> "$ini"
fi
done
done
rm -rf /tmp/*
#!/bin/sh
set -e
dir=/usr/src/php
usage() {
echo "usage: $0 COMMAND"
echo
echo "Manage php source tarball lifecycle."
echo
echo "Commands:"
echo " extract extract php source tarball into directory $dir if not already done."
echo " delete delete extracted php source located into $dir if not already done."
echo
}
case "$1" in
extract)
mkdir -p "$dir"
if [ ! -f "$dir/.docker-extracted" ]; then
tar -Jxf /usr/src/php.tar.xz -C "$dir" --strip-components=1
touch "$dir/.docker-extracted"
fi
;;
delete)
rm -rf /usr/src/php.tar.xz
;;
*)
usage
exit 1
;;
esac
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment