Skip to content

Instantly share code, notes, and snippets.

@royopa
Created April 17, 2019 11:05
Show Gist options
  • Save royopa/10bde32f881d736fcea2a5e36a92e7c3 to your computer and use it in GitHub Desktop.
Save royopa/10bde32f881d736fcea2a5e36a92e7c3 to your computer and use it in GitHub Desktop.
PHP 7.4
FROM debian:stretch-slim
ARG USER_PUID=1000
ARG USER_PGID=1000
ARG USER_NAME=php
RUN groupadd --gid $USER_PGID $USER_NAME \
&& useradd --uid $USER_PUID --gid $USER_NAME -m $USER_NAME
ENV PHPIZE_DEPS \
autoconf \
dpkg-dev \
file \
g++ \
gcc \
libc-dev \
make \
pkg-config \
bison \
re2c \
lcov \
snmp \
libxslt1-dev \
libtidy-dev \
libbz2-dev \
libc-client2007e-dev \
libkrb5-dev \
libpq-dev \
libonig-dev \
libzip-dev \
libgmp-dev \
libgdbm-dev \
libsnmp-dev
RUN apt-get update \
&& apt-get install -y \
$PHPIZE_DEPS \
ca-certificates \
curl \
--no-install-recommends && rm -r /var/lib/apt/lists/*
ENV PHP_INI_DIR /usr/local/etc/php
ENV PHP_CFLAGS="-fstack-protector-strong -fpic -fpie -O2"
ENV PHP_CPPFLAGS="$PHP_CFLAGS"
ENV PHP_LDFLAGS="-Wl,-O1 -Wl,--hash-style=both -pie"
RUN ln -fs /usr/lib/x86_64-linux-gnu/libsybdb.so /usr/lib/libsybdb.so \
&& ln -fs /usr/include/linux/igmp.h /usr/include/gmp.h \
&& ln -fs /usr/lib/i386-linux-gnu/libldap.so /usr/lib/ \
&& mkdir -p $PHP_INI_DIR/conf.d
RUN set -xe; \
fetchDeps=' \
wget \
unzip \
'; \
apt-get update; \
apt-get install -y --no-install-recommends $fetchDeps; \
rm -rf /var/lib/apt/lists/*; \
mkdir -p /usr/src; \
cd /usr/src; \
wget -O php-src-master.zip https://github.com/php/php-src/archive/master.zip;
COPY docker-php-source /usr/local/bin/
RUN set -eux; \
savedAptMark="$(apt-mark showmanual)"; \
apt-get update; \
apt-get install -y --no-install-recommends \
libcurl4-openssl-dev \
libedit-dev \
libsodium-dev \
libsqlite3-dev \
libssl-dev \
libxml2-dev \
zlib1g-dev \
; \
sed -e 's/stretch/buster/g' /etc/apt/sources.list > /etc/apt/sources.list.d/buster.list; \
{ \
echo 'Package: *'; \
echo 'Pin: release n=buster'; \
echo 'Pin-Priority: -10'; \
echo; \
echo 'Package: libargon2*'; \
echo 'Pin: release n=buster'; \
echo 'Pin-Priority: 990'; \
} > /etc/apt/preferences.d/argon2-buster; \
apt-get update; \
apt-get install -y --no-install-recommends libargon2-dev; \
rm -rf /var/lib/apt/lists/*; \
export \
CFLAGS="$PHP_CFLAGS" \
CPPFLAGS="$PHP_CPPFLAGS" \
LDFLAGS="$PHP_LDFLAGS";
RUN docker-php-source extract \
&& cd /usr/src/php \
&& gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \
&& debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)" \
&& ./buildconf \
&& ./configure \
--build="$gnuArch" \
--with-config-file-path="$PHP_INI_DIR" \
--with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \
--enable-gcov \
--enable-wddx \
--enable-soap \
--enable-bcmath \
--enable-calendar \
--enable-dba \
--enable-exif \
--enable-ftp \
--enable-pcntl \
--enable-shmop \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-mbstring \
--enable-intl \
--enable-sigchild \
--enable-libgcc \
--enable-gd-jis-conv \
--enable-zip \
--enable-debug \
--enable-phpdbg \
--enable-fpm \
--enable-xmlreader \
--with-xsl \
--with-tidy \
--with-bz2 \
--with-imap \
--with-imap-ssl \
--with-kerberos \
--with-openssl \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-pdo-sqlite \
--with-pgsql \
--with-pdo-pgsql \
--with-zlib \
--with-gd \
--with-gmp \
--with-xmlrpc \
--with-snmp \
--with-gdbm \
&& make -j "$(nproc)" \
&& make install \
&& { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } \
&& make clean
# CMD ["/bin/bash"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment