Skip to content

Instantly share code, notes, and snippets.

@wirwolf
Last active September 15, 2021 08:33
Show Gist options
  • Save wirwolf/d7a462fb884848ad561587e00833da38 to your computer and use it in GitHub Desktop.
Save wirwolf/d7a462fb884848ad561587e00833da38 to your computer and use it in GitHub Desktop.
FROM php:5.3-fpm
# curl for cmd
RUN apt update && apt install -y curl procps
# -------------------- Installing PHP Extension: apcu --------------------
RUN set -eux \
# Installation: Generic
# Type: PECL extension
# Default: Pecl command
&& pecl install apcu-4.0.7 \
&& docker-php-ext-enable apcu \
&& true
# -------------------- Installing PHP Extension: bz2 --------------------
RUN set -eux \
# Installation: Generic
# Type: Built-in extension
&& apt install -y libbz2-dev \
&& docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) bz2 \
&& true
# -------------------- Installing PHP Extension: bcmath --------------------
RUN set -eux \
# Installation: Generic
# Type: Built-in extension
&& docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) bcmath \
&& true
# -------------------- Installing PHP Extension: calendar --------------------
RUN set -eux \
# Installation: Generic
# Type: Built-in extension
&& docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) calendar \
&& true
# -------------------- Installing PHP Extension: exif --------------------
RUN set -eux \
# Installation: Generic
# Type: Built-in extension
&& docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) exif \
&& true
# -------------------- Installing PHP Extension: ftp --------------------
RUN set -eux \
# Installation: Generic
# Type: Built-in extension
&& apt install -y libssl-dev \
&& docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) ftp \
&& true
# -------------------- Installing PHP Extension: gettext --------------------
RUN set -eux \
# Installation: Generic
# Type: Built-in extension
&& docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) gettext \
&& true
# -------------------- Installing PHP Extension: gmp --------------------
RUN set -eux \
# Installation: Generic
# Type: Built-in extension
&& apt install -y libgmp-dev \
&& ln --verbose --symbolic --force /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h \
&& docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) gmp \
&& true
# -------------------- Installing PHP Extension: gd --------------------
RUN set -eux \
# Installation: Generic
# Type: Built-in extension
# Custom: configure command
&& apt-get install -y libpng-dev libwebp-dev libjpeg62-turbo-dev libpng-dev libxpm-dev libfreetype6-dev \
&& docker-php-ext-configure gd --with-gd --with-jpeg-dir --with-png-dir --with-zlib-dir --with-xpm-dir --with-freetype-dir --enable-gd-native-ttf \
&& docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) gd \
&& true
# -------------------- Installing PHP Extension: imap --------------------
RUN set -eux \
# Installation: Generic
# Type: Built-in extension
# Custom: configure command
&& apt install -y libc-client-dev libkrb5-dev \
&& docker-php-ext-configure imap --with-kerberos --with-imap-ssl \
&& docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) imap \
&& true
# -------------------- Installing PHP Extension: imagick --------------------
RUN set -eux \
# Installation: Generic
# Type: PECL extension
# Default: Pecl command
&& apt-get install -y libmagickwand-dev \
&& pecl install imagick \
&& docker-php-ext-enable imagick \
&& true
# -------------------- Installing PHP Extension: intl --------------------
RUN set -eux \
# Installation: Generic
# Type: Built-in extension
&& apt install -y libicu-dev \
&& docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) intl \
&& true
# -------------------- Installing PHP Extension: ldap --------------------
RUN set -eux \
# Installation: Generic
# Type: Built-in extension
&& apt install -y libldap2-dev libsasl2-dev \
&& ln --verbose --symbolic --force /usr/lib/x86_64-linux-gnu/libldap* /usr/lib/ \
&& docker-php-ext-configure ldap --with-ldap --with-ldap-sasl \
&& docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) ldap \
&& true
# -------------------- Installing PHP Extension: mbstring --------------------
RUN set -eux \
# Installation: Generic
# Type: Built-in extension
&& docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) mbstring \
&& true
# -------------------- Installing PHP Extension: mcrypt --------------------
RUN set -eux \
# Installation: Generic
# Type: Built-in extension
&& apt install -y libldap2-dev libmcrypt-dev \
&& docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) mcrypt \
&& true
# -------------------- Installing PHP Extension: memcache --------------------
RUN set -eux \
# Installation: Generic
# Type: PECL extension
# Default: Pecl command
&& apt install -y libmemcached-dev \
&& pecl install memcache-3.0.8 \
&& docker-php-ext-enable memcache \
&& true
# -------------------- Installing PHP Extension: memcached --------------------
RUN set -eux \
# Installation: Generic
# Type: PECL extension
# Default: Pecl command
&& apt install -y libmemcached-dev \
&& pecl install memcached-2.2.0 \
&& docker-php-ext-enable memcached \
&& true
# -------------------- Installing PHP Extension: mysqli --------------------
RUN set -eux \
# Installation: Generic
# Type: Built-in extension
&& apt install -y libldap2-dev libmcrypt-dev \
&& docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) mysqli \
&& true
# -------------------- Installing PHP Extension: pdo_dblib --------------------
RUN set -eux \
# Generic pre-command
# Installation: Generic
# Type: Built-in extension
&& apt install -y freetds-dev freetds-common freetds-bin \
&& ln --verbose --symbolic --force /usr/lib/x86_64-linux-gnu/libsybdb.* /usr/lib/ \
&& docker-php-ext-configure pdo_dblib --with-sybase=/usr/local/freetds \
&& docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) pdo_dblib \
&& true
# -------------------- Installing PHP Extension: pdo_odbc --------------------
RUN set -eux \
# Installation: Generic
# Type: Built-in extension
# Custom: configure command
&& apt-get install unixodbc-dev -y \
&& docker-php-ext-configure pdo_odbc --with-pdo-odbc=unixODBC,/usr \
&& docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) pdo_odbc \
&& true
# -------------------- Installing PHP Extension: pdo_pgsql --------------------
RUN set -eux \
# Installation: Generic
# Type: Built-in extension
&& apt install -y libpq-dev \
&& docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) pdo_pgsql \
&& true
# -------------------- Installing PHP Extension: pdo_mysql --------------------
RUN set -eux \
# Installation: Generic
# Type: Built-in extension
&& apt install -y libzip-dev \
&& docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) pdo_mysql \
&& true
# -------------------- Installing PHP Extension: shmop --------------------
RUN set -eux \
# Installation: Generic
# Type: Built-in extension
&& docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) shmop \
&& true
# -------------------- Installing PHP Extension: snmp --------------------
RUN set -eux \
# Installation: Generic
# Type: Built-in extension
&& apt install -y libsnmp-dev snmp \
&& docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) snmp \
&& true
# -------------------- Installing PHP Extension: sysvmsg --------------------
RUN set -eux \
# Installation: Generic
# Type: Built-in extension
&& docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) sysvmsg \
&& true
# -------------------- Installing PHP Extension: dba --------------------
RUN set -eux \
# Installation: Generic
# Type: Built-in extension
&& docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) dba \
&& true
# -------------------- Installing PHP Extension: enchant --------------------
RUN set -eux \
# Installation: Generic
# Type: Built-in extension
&& apt install -y libenchant-dev \
&& docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) enchant \
&& true
# -------------------- Installing PHP Extension: mssql --------------------
RUN set -eux \
# Installation: Generic
# Type: Built-in extension
&& apt install -y freetds-dev \
&& ln --verbose --symbolic --force /usr/lib/x86_64-linux-gnu/libsybdb.a /usr/lib \
&& docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) mssql \
&& true
# -------------------- Installing PHP Extension: mysql --------------------
RUN set -eux \
# Installation: Generic
# Type: Built-in extension
&& docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) mysql \
&& true
# -------------------- Installing PHP Extension: pgsql --------------------
RUN set -eux \
# Installation: Generic
# Type: Built-in extension
&& apt-get install -y libpq-dev \
&& docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) pgsql \
&& true
# -------------------- Installing PHP Extension: pspell --------------------
RUN set -eux \
# Installation: Generic
# Type: Built-in extension
&& apt install -y libpspell-dev \
&& docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) pspell \
&& true
# -------------------- Installing PHP Extension: pspell --------------------
RUN set -eux \
# Installation: Generic
# Type: Built-in extension
&& apt install -y libpspell-dev \
&& docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) pspell \
&& true
# -------------------- Installing PHP Extension: tidy --------------------
RUN set -eux \
# Installation: Version specific
# Type: Built-in extension
# Installation
&& apt install -y libtidy-dev \
&& docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) tidy \
&& true
# -------------------- Installing PHP Extension: pcntl --------------------
RUN set -eux \
# Installation: Generic
# Type: Built-in extension
&& docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) pcntl \
&& true
# -------------------- Installing PHP Extension: opcache --------------------
RUN set -eux \
# Installation: Generic
# Type: Built-in extension
&& docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) opcache \
&& true
# -------------------- Installing PHP Extension: odbc --------------------
RUN set -ex; \
# Installation: Generic
# Type: Built-in extension
# Custom: configure command
apt install -y unixodbc-dev libpq-dev; \
ln --verbose --symbolic --force /usr/include /usr/local/incl; \
ln --verbose --symbolic --force /usr/lib/x86_64-linux-gnu/libodbc.a /usr/local/lib/odbclib.a; \
# https://github.com/docker-library/php/issues/103#issuecomment-353674490
docker-php-source extract; \
{ \
echo '# https://github.com/docker-library/php/issues/103#issuecomment-353674490'; \
echo 'AC_DEFUN([PHP_ALWAYS_SHARED],[])dnl'; \
echo; \
cat /usr/src/php/ext/odbc/config.m4; \
} > temp.m4; \
mv temp.m4 /usr/src/php/ext/odbc/config.m4; \
docker-php-ext-configure odbc --with-unixODBC=shared,/usr; \
docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) odbc; \
docker-php-source delete \
&& true
# -------------------- Installing PHP Extension: propro --------------------
RUN set -eux \
# Installation: Generic
# Type: PECL extension
# Default: Pecl command
&& pecl install propro-1.0.0 \
&& docker-php-ext-enable propro \
&& true
# -------------------- Installing PHP Extension: raphf --------------------
RUN set -eux \
# Installation: Generic
# Type: PECL extension
# Default: Pecl command
&& pecl install raphf-1.0.4 \
&& docker-php-ext-enable raphf \
&& true
# -------------------- Installing PHP Extension: http --------------------
RUN set -eux \
# Installation: Generic
# Type: PECL extension
# Default: Pecl command
# Load http module in the end loading all extension
&& pecl install pecl_http-2.0.6 \
&& docker-php-ext-enable http \
&& mv -v /usr/local/etc/php/conf.d/docker-php-ext-http.ini /usr/local/etc/php/conf.d/docker-php-ext-z-http.ini \
&& true
# -------------------- Installing PHP Extension: recode --------------------
RUN set -eux \
# Installation: Generic
# Type: Built-in extension
&& apt-get install -y librecode-dev \
&& docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) recode \
&& true
# -------------------- Installing PHP Extension: sockets --------------------
RUN set -eux \
# Installation: Generic
# Type: Built-in extension
&& docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) sockets \
&& true
# -------------------- Installing PHP Extension: wddx --------------------
RUN set -eux \
# Installation: Generic
# Type: Built-in extension
&& apt install -y libxml2-dev \
&& docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) wddx \
&& true
# -------------------- Installing PHP Extension: xsl --------------------
RUN set -eux \
# Installation: Generic
# Type: Built-in extension
&& apt install -y libxslt-dev \
&& docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) xsl \
&& true
# -------------------- Installing PHP Extension: xml --------------------
RUN set -eux \
# Installation: Generic
# Type: Built-in extension
&& docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) xml \
&& true
# -------------------- Installing PHP Extension: xmlreader --------------------
RUN set -eux \
# Installation: Generic
# Type: Built-in extension
&& docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) xmlreader \
&& true
# -------------------- Installing PHP Extension: xmlrpc --------------------
RUN set -eux \
# Installation: Generic
# Type: Built-in extension
&& docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) xmlrpc \
&& true
# -------------------- Installing PHP Extension: xmlwriter --------------------
RUN set -eux \
# Installation: Generic
# Type: Built-in extension
&& docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) xmlwriter \
&& true
# -------------------- Installing PHP Extension: zip --------------------
RUN set -eux \
# Installation: Generic
# Type: Built-in extension
&& apt install -y libzip-dev \
&& docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) zip \
&& true
# -------------------- Installing PHP Extension: oauth --------------------
RUN set -eux \
# Installation: Generic
# Type: PECL extension
# Default: Pecl command
&& pecl install oauth-1.2.3 \
&& docker-php-ext-enable oauth \
&& true
# -------------------- Installing PHP Extension: ssh2 --------------------
RUN set -eux \
# Installation: Generic
# Type: PECL extension
# Default: Pecl command
&& apt-get install -y libssh2-1-dev \
&& pecl install ssh2-0.12 \
&& docker-php-ext-enable ssh2 \
&& true
# -------------------- Installing PHP Extension: redis --------------------
RUN set -eux \
# Installation: Generic
# Type: PECL extension
# Default: Pecl command
&& pecl install redis-2.2.8 \
&& docker-php-ext-enable redis \
&& true
# -------------------- Installing PHP Extension: igbinary --------------------
RUN set -eux \
# Installation: Generic
# Type: PECL extension
# Default: Pecl command
&& pecl install igbinary-1.2.1 \
&& docker-php-ext-enable igbinary \
&& true
# -------------------- Installing PHP Extension: soap --------------------
RUN set -eux \
# Installation: Generic
# Type: Built-in extension
# Custom: configure command
&& docker-php-ext-configure soap --with-libxml-dir=/usr \
&& docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) soap \
&& true
# -------------------- Installing mysqldump and mysql (client) --------------------
RUN set -eux \
# Installation: Generic
# Type: Built-in extension
# Custom: configure command
&& apt-get install -y mysql-client \
&& true
###
### Envs
###
ENV MY_USER="php" \
MY_GROUP="php" \
MY_UID="1000" \
MY_GID="1000"
###
### User/Group
###
RUN set -eux \
&& groupadd -g ${MY_GID} -r ${MY_GROUP} \
&& useradd -u ${MY_UID} -m -s /bin/bash -g ${MY_GROUP} ${MY_USER}
###
### Configure
###
RUN set -eux \
&& rm -rf /usr/local/etc/php-fpm.d \
&& mkdir -p /usr/local/etc/php-fpm.d \
&& mkdir -p /var/lib/php/session \
&& mkdir -p /var/lib/php/wsdlcache \
&& chown -R ${MY_USER}:${MY_GROUP} /var/lib/php/session \
&& chown -R ${MY_USER}:${MY_GROUP} /var/lib/php/wsdlcache
###
### Copy files
###
###
COPY ./data/php.ini /usr/local/etc/php/conf.d/default-php.ini
COPY ./data/php-fpm.conf /usr/local/etc/php-fpm.conf
COPY ./docker-entrypoint.sh /docker-entrypoint.sh
COPY ./data/docker-entrypoint.d /docker-entrypoint.d
RUN chmod +x /docker-entrypoint.sh
###
### Verify
###
RUN set -eux \
&& echo "date.timezone=UTC" > /usr/local/etc/php/php.ini \
&& php -v | grep -oE 'PHP\s[.0-9]+' | grep -oE '[.0-9]+' | grep '^5.6' \
&& /usr/local/sbin/php-fpm --test \
\
&& PHP_ERROR="$( php -v 2>&1 1>/dev/null )" \
&& if [ -n "${PHP_ERROR}" ]; then echo "${PHP_ERROR}"; false; fi \
&& PHP_ERROR="$( php -i 2>&1 1>/dev/null )" \
&& if [ -n "${PHP_ERROR}" ]; then echo "${PHP_ERROR}"; false; fi \
\
&& PHP_FPM_ERROR="$( php-fpm -v 2>&1 1>/dev/null )" \
&& if [ -n "${PHP_FPM_ERROR}" ]; then echo "${PHP_FPM_ERROR}"; false; fi \
&& PHP_FPM_ERROR="$( php-fpm -i 2>&1 1>/dev/null )" \
&& if [ -n "${PHP_FPM_ERROR}" ]; then echo "${PHP_FPM_ERROR}"; false; fi \
&& rm -f /usr/local/etc/php/php.ini
###
### Ports
###
EXPOSE 9000
###
### Entrypoint
###
CMD ["/usr/local/sbin/php-fpm"]
ENTRYPOINT ["/docker-entrypoint.sh"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment