зеркало из https://github.com/microsoft/Oryx.git
Reduce size of images: Common base for PHP runtime images, .NET Core tools (#413)
This commit is contained in:
Родитель
9677d5e807
Коммит
6e43e9528f
|
@ -257,7 +257,7 @@ paket-files/
|
|||
images/runtime/node/*/Dockerfile
|
||||
images/runtime/dotnetcore/*/Dockerfile
|
||||
images/runtime/python/*.*/
|
||||
images/runtime/php/*.*/
|
||||
images/runtime/php/*.*/Dockerfile
|
||||
|
||||
# Go packages from GitHub
|
||||
src/startupscriptgenerator/bin/
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# This file was auto-generated from 'constants.yaml'. Changes may be overridden.
|
||||
|
||||
DOT_NET_CORE_RUNTIME_BASE_TAG='20191025.2'
|
||||
DOT_NET_CORE_RUNTIME_BASE_TAG='20191104.7'
|
||||
NET_CORE_APP_10='1.0.16'
|
||||
NET_CORE_APP_11='1.1.14'
|
||||
NET_CORE_APP_20='2.0.9'
|
||||
|
|
|
@ -51,6 +51,12 @@ function execAllGenerateDockerfiles()
|
|||
for generateDockerFile in $generateDockerfiles; do
|
||||
echo
|
||||
echo "Executing '$generateDockerFile'..."
|
||||
echo
|
||||
"$generateDockerFile"
|
||||
done
|
||||
}
|
||||
|
||||
function showDockerImageSizes()
|
||||
{
|
||||
docker system df -v
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# This file was auto-generated from 'constants.yaml'. Changes may be overridden.
|
||||
|
||||
NODE_RUNTIME_BASE_TAG='20191025.2'
|
||||
YARN_CACHE_BASE_TAG='20191025.2'
|
||||
NODE_RUNTIME_BASE_TAG='20191104.7'
|
||||
YARN_CACHE_BASE_TAG='20191104.7'
|
||||
YARN_VERSION='1.17.3'
|
||||
YARN_MINOR_VERSION='1.17'
|
||||
YARN_MAJOR_VERSION='1'
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
# This file was auto-generated from 'constants.yaml'. Changes may be overridden.
|
||||
|
||||
PHP_BUILD_BASE_TAG='20191025.2'
|
||||
PHP_RUNTIME_BASE_TAG='20191025.2'
|
||||
PHP_BUILD_BASE_TAG='20191104.7'
|
||||
PHP_RUNTIME_BASE_TAG='20191104.7'
|
||||
COMPOSER_VERSION='1.9.0'
|
||||
COMPOSER_SHA384='a5c698ffe4b8e849a443b120cd5ba38043260d5c4023dbf93e1558871f1f07f58274fc6f4c93bcfd858c6bd0775cd8d1'
|
||||
PHP73_VERSION='7.3.10'
|
||||
PHP73_VERSION='7.3.11'
|
||||
PHP73_KEYS='CBAF69F173A0FEA4B537F470D66C9593118BCCB6 F38252826ACD957EF380D39F2F7956BC5DA04B5D'
|
||||
PHP73_TAR_SHA256='42f00a15419e05771734b7159c8d39d639b8a5a6770413adfa2615f6f923d906'
|
||||
PHP72_VERSION='7.2.23'
|
||||
PHP73_TAR_SHA256='657cf6464bac28e9490c59c07a2cf7bb76c200f09cfadf6e44ea64e95fa01021'
|
||||
PHP72_VERSION='7.2.24'
|
||||
PHP72_KEYS='1729F83938DA44E27BA0F4D3DBDB397470D12172 B1B44D8F021E4E2D6021E995DC9FF8D3EE5AF27F'
|
||||
PHP72_TAR_SHA256='74e045ec8ff26290db6a3688826dcdf43b87bc509e508e9cb76dab742804ca14'
|
||||
PHP72_TAR_SHA256='a6a6cc03388060aa5f8f9e45799b72bce1c7ed7b9d7b3f1187787202aad91d25'
|
||||
PHP70_VERSION='7.0.33'
|
||||
PHP70_KEYS='1A4E8B7277C42E53DBA9C7B9BCAA30EA9C0D5763 6E4F6AB321FDC07F2C332E3AC2BF0BC433CFC8B3'
|
||||
PHP70_TAR_SHA256='ab8c5be6e32b1f8d032909dedaaaa4bbb1a209e519abb01a52ce3914f9a13d96'
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# This file was auto-generated from 'constants.yaml'. Changes may be overridden.
|
||||
|
||||
PYTHON_BASE_TAG='20191025.2'
|
||||
PYTHON_BASE_TAG='20191104.7'
|
||||
PIP_VERSION='19.3.1'
|
||||
PYTHON27_VERSION='2.7.17'
|
||||
PYTHON36_VERSION='3.6.9'
|
||||
|
|
|
@ -151,6 +151,9 @@ echo
|
|||
echo "List of images tagged (from '$ACR_BUILD_IMAGES_ARTIFACTS_FILE'):"
|
||||
cat $ACR_BUILD_IMAGES_ARTIFACTS_FILE
|
||||
|
||||
echo
|
||||
showDockerImageSizes
|
||||
|
||||
echo
|
||||
dockerCleanupIfRequested
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
# Licensed under the MIT license.
|
||||
# --------------------------------------------------------------------------------------------
|
||||
|
||||
set -e
|
||||
set -ex
|
||||
|
||||
declare -r REPO_DIR=$( cd $( dirname "$0" ) && cd .. && pwd )
|
||||
|
||||
|
@ -25,7 +25,20 @@ then
|
|||
fi
|
||||
fi
|
||||
|
||||
labels="--label com.microsoft.oryx.git-commit=$GIT_COMMIT --label com.microsoft.oryx.build-number=$BUILD_NUMBER"
|
||||
echo
|
||||
echo "Building the common base image '$RUNTIME_BASE_IMAGE_NAME'..."
|
||||
echo
|
||||
# Build the common base image first, so other images that depend on it get the latest version.
|
||||
# We don't retrieve this image from a repository but rather build locally to make sure we get
|
||||
# the latest version of its own base image.
|
||||
docker build \
|
||||
--pull \
|
||||
-f "$RUNTIME_BASE_IMAGE_DOCKERFILE_PATH" \
|
||||
-t "$RUNTIME_BASE_IMAGE_NAME" \
|
||||
$REPO_DIR
|
||||
|
||||
labels="--label com.microsoft.oryx.git-commit=$GIT_COMMIT"
|
||||
labels="$labels --label com.microsoft.oryx.build-number=$BUILD_NUMBER"
|
||||
|
||||
execAllGenerateDockerfiles "$runtimeImagesSourceDir"
|
||||
|
||||
|
@ -37,15 +50,15 @@ then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Build the common base image first, so other images that depend on it get the latest version.
|
||||
# We don't retrieve this image from a repository but rather build locally to make sure we get
|
||||
# the latest version of its own base image.
|
||||
docker build --pull -f "$RUNTIME_BASE_IMAGE_DOCKERFILE_PATH" -t "$RUNTIME_BASE_IMAGE_NAME" $REPO_DIR
|
||||
|
||||
# Write the list of images that were built to artifacts folder
|
||||
mkdir -p "$BASE_IMAGES_ARTIFACTS_FILE_PREFIX"
|
||||
ARTIFACTS_FILE="$BASE_IMAGES_ARTIFACTS_FILE_PREFIX/$runtimeSubDir-runtimeimage-bases.txt"
|
||||
|
||||
initFile="$runtimeImagesSourceDir/buildRunTimeImageBases_Init.sh"
|
||||
if [ -f "$initFile" ]; then
|
||||
$initFile
|
||||
fi
|
||||
|
||||
clearedOutput=false
|
||||
for dockerFile in $dockerFiles; do
|
||||
dockerFileDir=$(dirname "${dockerFile}")
|
||||
|
@ -99,5 +112,8 @@ then
|
|||
cat $ARTIFACTS_FILE
|
||||
fi
|
||||
|
||||
echo
|
||||
showDockerImageSizes
|
||||
|
||||
echo
|
||||
dockerCleanupIfRequested
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
# Licensed under the MIT license.
|
||||
# --------------------------------------------------------------------------------------------
|
||||
|
||||
set -e
|
||||
set -ex
|
||||
|
||||
declare -r REPO_DIR=$( cd $( dirname "$0" ) && cd .. && pwd )
|
||||
|
||||
|
@ -35,6 +35,16 @@ then
|
|||
args="$args --build-arg RELEASE_TAG_NAME=$RELEASE_TAG_NAME"
|
||||
fi
|
||||
|
||||
# Build the common base image first, so other images that depend on it get the latest version.
|
||||
# We don't retrieve this image from a repository but rather build locally to make sure we get
|
||||
# the latest version of its own base image.
|
||||
|
||||
docker build \
|
||||
--pull \
|
||||
-f "$RUNTIME_BASE_IMAGE_DOCKERFILE_PATH" \
|
||||
-t "$RUNTIME_BASE_IMAGE_NAME" \
|
||||
$REPO_DIR
|
||||
|
||||
execAllGenerateDockerfiles "$runtimeImagesSourceDir"
|
||||
|
||||
# The common base image is built separately, so we ignore it
|
||||
|
@ -45,16 +55,6 @@ then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Build the common base image first, so other images that depend on it get the latest version.
|
||||
# We don't retrieve this image from a repository but rather build locally to make sure we get
|
||||
# the latest version of its own base image.
|
||||
|
||||
docker build \
|
||||
--pull \
|
||||
-f "$RUNTIME_BASE_IMAGE_DOCKERFILE_PATH" \
|
||||
-t "$RUNTIME_BASE_IMAGE_NAME" \
|
||||
$REPO_DIR
|
||||
|
||||
# Write the list of images that were built to artifacts folder
|
||||
mkdir -p "$ARTIFACTS_DIR/images"
|
||||
|
||||
|
@ -114,5 +114,8 @@ then
|
|||
cat $ACR_RUNTIME_IMAGES_ARTIFACTS_FILE
|
||||
fi
|
||||
|
||||
echo
|
||||
showDockerImageSizes
|
||||
|
||||
echo
|
||||
dockerCleanupIfRequested
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
file-name-prefix: __
|
||||
- name: dot-net-core-run-time-versions
|
||||
constants:
|
||||
dot-net-core-runtime-base-tag: 20191025.2
|
||||
dot-net-core-runtime-base-tag: 20191104.7
|
||||
net-core-app-10: 1.0.16
|
||||
net-core-app-11: 1.1.14
|
||||
net-core-app-20: 2.0.9
|
||||
|
@ -54,7 +54,7 @@
|
|||
file-name-prefix: __
|
||||
- name: python-versions
|
||||
constants:
|
||||
python-base-tag: 20191025.2
|
||||
python-base-tag: 20191104.7
|
||||
pip-version: 19.3.1
|
||||
python27-version: 2.7.17
|
||||
python36-version: 3.6.9
|
||||
|
@ -69,17 +69,17 @@
|
|||
file-name-prefix: __
|
||||
- name: php-versions
|
||||
constants:
|
||||
php-build-base-tag: 20191025.2
|
||||
php-runtime-base-tag: 20191025.2
|
||||
php-build-base-tag: 20191104.7
|
||||
php-runtime-base-tag: 20191104.7
|
||||
composer-version: 1.9.0
|
||||
composer-sha384: a5c698ffe4b8e849a443b120cd5ba38043260d5c4023dbf93e1558871f1f07f58274fc6f4c93bcfd858c6bd0775cd8d1
|
||||
# hashes are for .tar.xz
|
||||
php73-version: 7.3.10
|
||||
php73-version: 7.3.11
|
||||
php73-keys: CBAF69F173A0FEA4B537F470D66C9593118BCCB6 F38252826ACD957EF380D39F2F7956BC5DA04B5D
|
||||
php73-tar-sha256: 42f00a15419e05771734b7159c8d39d639b8a5a6770413adfa2615f6f923d906
|
||||
php72-version: 7.2.23
|
||||
php73-tar-sha256: 657cf6464bac28e9490c59c07a2cf7bb76c200f09cfadf6e44ea64e95fa01021
|
||||
php72-version: 7.2.24
|
||||
php72-keys: 1729F83938DA44E27BA0F4D3DBDB397470D12172 B1B44D8F021E4E2D6021E995DC9FF8D3EE5AF27F
|
||||
php72-tar-sha256: 74e045ec8ff26290db6a3688826dcdf43b87bc509e508e9cb76dab742804ca14
|
||||
php72-tar-sha256: a6a6cc03388060aa5f8f9e45799b72bce1c7ed7b9d7b3f1187787202aad91d25
|
||||
php70-version: 7.0.33
|
||||
php70-keys: 1A4E8B7277C42E53DBA9C7B9BCAA30EA9C0D5763 6E4F6AB321FDC07F2C332E3AC2BF0BC433CFC8B3
|
||||
php70-tar-sha256: ab8c5be6e32b1f8d032909dedaaaa4bbb1a209e519abb01a52ce3914f9a13d96
|
||||
|
@ -109,8 +109,8 @@
|
|||
directory: src/startupscriptgenerator/src/common/consts
|
||||
- name: node-versions
|
||||
constants:
|
||||
node-runtime-base-tag: 20191025.2
|
||||
yarn-cache-base-tag: 20191025.2
|
||||
node-runtime-base-tag: 20191104.7
|
||||
yarn-cache-base-tag: 20191104.7
|
||||
yarn-version: 1.17.3
|
||||
yarn-minor-version: 1.17
|
||||
yarn-major-version: 1
|
||||
|
|
|
@ -44,7 +44,6 @@ RUN . /tmp/scripts/__dotNetCoreSdkVersions.sh && \
|
|||
DOTNET_SDK_URL=https://dotnetcli.blob.core.windows.net/dotnet/Sdk/$DOTNET_SDK_VER/dotnet-dev-debian.9-x64.$DOTNET_SDK_VER.tar.gz \
|
||||
# To save disk space do not install packages for this old version which is soon going to be out of support
|
||||
INSTALL_PACKAGES=false \
|
||||
INSTALL_TOOLS=true \
|
||||
/tmp/scripts/installDotNetCore.sh
|
||||
|
||||
RUN . /tmp/scripts/__dotNetCoreSdkVersions.sh && \
|
||||
|
@ -63,7 +62,6 @@ RUN . /tmp/scripts/__dotNetCoreSdkVersions.sh && \
|
|||
DOTNET_SDK_SHA=$DOT_NET_CORE_31_SDK_SHA512 \
|
||||
# Since this is a preview version, do not warm up with nuget packages
|
||||
INSTALL_PACKAGES=false \
|
||||
INSTALL_TOOLS=true \
|
||||
/tmp/scripts/installDotNetCore.sh
|
||||
|
||||
RUN set -ex \
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
Dockerfile
|
||||
Dockerfile
|
||||
Dockerfile.base
|
|
@ -0,0 +1,34 @@
|
|||
FROM php:5.6-apache-stretch
|
||||
|
||||
# persistent / runtime deps
|
||||
RUN set -eux; \
|
||||
apt-get update; \
|
||||
apt-get install -y --no-install-recommends \
|
||||
libzip-dev \
|
||||
libpng-dev \
|
||||
libjpeg-dev \
|
||||
libpq-dev \
|
||||
libldap2-dev \
|
||||
libldb-dev \
|
||||
libicu-dev \
|
||||
libgmp-dev \
|
||||
libmagickwand-dev \
|
||||
libc-client-dev \
|
||||
libtidy-dev \
|
||||
libkrb5-dev \
|
||||
libxslt-dev \
|
||||
unixodbc-dev \
|
||||
openssh-server \
|
||||
vim \
|
||||
curl \
|
||||
wget \
|
||||
tcptraceroute \
|
||||
mariadb-client \
|
||||
openssl \
|
||||
; \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN set -eux; \
|
||||
apt-get update && apt-get install -y libmcrypt-dev \
|
||||
&& docker-php-ext-install mcrypt \
|
||||
&& docker-php-ext-enable mcrypt
|
|
@ -0,0 +1,235 @@
|
|||
# Commit b4319e8f767f1200c9013e08baf2c34b9c84e301 from repo https://github.com/docker-library/php.git
|
||||
FROM php-run-base
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y \
|
||||
libmcrypt-dev \
|
||||
&& rm -rf /var/lib/apt/lists/
|
||||
|
||||
ENV PHP_INI_DIR /usr/local/etc/php
|
||||
RUN mkdir -p $PHP_INI_DIR/conf.d
|
||||
|
||||
##<autogenerated>##
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
apache2 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV APACHE_CONFDIR /etc/apache2
|
||||
ENV APACHE_ENVVARS $APACHE_CONFDIR/envvars
|
||||
|
||||
RUN set -eux; \
|
||||
\
|
||||
# generically convert lines like
|
||||
# export APACHE_RUN_USER=www-data
|
||||
# into
|
||||
# : ${APACHE_RUN_USER:=www-data}
|
||||
# export APACHE_RUN_USER
|
||||
# so that they can be overridden at runtime ("-e APACHE_RUN_USER=...")
|
||||
sed -ri 's/^export ([^=]+)=(.*)$/: ${\1:=\2}\nexport \1/' "$APACHE_ENVVARS"; \
|
||||
\
|
||||
# setup directories and permissions
|
||||
. "$APACHE_ENVVARS"; \
|
||||
for dir in \
|
||||
"$APACHE_LOCK_DIR" \
|
||||
"$APACHE_RUN_DIR" \
|
||||
"$APACHE_LOG_DIR" \
|
||||
/var/www/html \
|
||||
; do \
|
||||
rm -rvf "$dir"; \
|
||||
mkdir -p "$dir"; \
|
||||
chown "$APACHE_RUN_USER:$APACHE_RUN_GROUP" "$dir"; \
|
||||
# allow running as an arbitrary user (https://github.com/docker-library/php/issues/743)
|
||||
chmod 777 "$dir"; \
|
||||
done; \
|
||||
\
|
||||
# logs should go to stdout / stderr
|
||||
ln -sfT /dev/stderr "$APACHE_LOG_DIR/error.log"; \
|
||||
ln -sfT /dev/stdout "$APACHE_LOG_DIR/access.log"; \
|
||||
ln -sfT /dev/stdout "$APACHE_LOG_DIR/other_vhosts_access.log"; \
|
||||
chown -R --no-dereference "$APACHE_RUN_USER:$APACHE_RUN_GROUP" "$APACHE_LOG_DIR"
|
||||
|
||||
# Apache + PHP requires preforking Apache for best results
|
||||
RUN a2dismod mpm_event && a2enmod mpm_prefork
|
||||
|
||||
# PHP files should be handled by PHP, and should be preferred over any other file type
|
||||
RUN { \
|
||||
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 "$APACHE_CONFDIR/conf-available/docker-php.conf" \
|
||||
&& a2enconf docker-php
|
||||
|
||||
ENV PHP_EXTRA_BUILD_DEPS apache2-dev
|
||||
ENV PHP_EXTRA_CONFIGURE_ARGS --with-apxs2 --disable-cgi
|
||||
##</autogenerated>##
|
||||
|
||||
# Apply stack smash protection to functions using local buffers and alloca()
|
||||
# Make PHP's main executable position-independent (improves ASLR security mechanism, and has no performance impact on x86_64)
|
||||
# Enable optimization (-O2)
|
||||
# Enable linker optimization (this sorts the hash buckets to improve cache locality, and is non-default)
|
||||
# Adds GNU HASH segments to generated executables (this is used if present, and is much faster than sysv hash; in this configuration, sysv hash is also generated)
|
||||
# https://github.com/docker-library/php/issues/272
|
||||
ENV PHP_CFLAGS="-fstack-protector-strong -fpic -fpie -O2"
|
||||
ENV PHP_CPPFLAGS="$PHP_CFLAGS"
|
||||
ENV PHP_LDFLAGS="-Wl,-O1 -Wl,--hash-style=both -pie"
|
||||
|
||||
ENV GPG_KEYS 1A4E8B7277C42E53DBA9C7B9BCAA30EA9C0D5763 6E4F6AB321FDC07F2C332E3AC2BF0BC433CFC8B3
|
||||
|
||||
ENV PHP_VERSION 7.0.33
|
||||
ENV PHP_URL="https://secure.php.net/get/php-7.0.33.tar.xz/from/this/mirror" PHP_ASC_URL="https://secure.php.net/get/php-7.0.33.tar.xz.asc/from/this/mirror"
|
||||
ENV PHP_SHA256="ab8c5be6e32b1f8d032909dedaaaa4bbb1a209e519abb01a52ce3914f9a13d96" PHP_MD5=""
|
||||
|
||||
RUN set -xe; \
|
||||
\
|
||||
fetchDeps=' \
|
||||
wget \
|
||||
'; \
|
||||
if ! command -v gpg > /dev/null; then \
|
||||
fetchDeps="$fetchDeps \
|
||||
dirmngr \
|
||||
gnupg \
|
||||
"; \
|
||||
fi; \
|
||||
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.tar.xz "$PHP_URL"; \
|
||||
\
|
||||
if [ -n "$PHP_SHA256" ]; then \
|
||||
echo "$PHP_SHA256 *php.tar.xz" | sha256sum -c -; \
|
||||
fi; \
|
||||
if [ -n "$PHP_MD5" ]; then \
|
||||
echo "$PHP_MD5 *php.tar.xz" | md5sum -c -; \
|
||||
fi; \
|
||||
\
|
||||
if [ -n "$PHP_ASC_URL" ]; then \
|
||||
wget -O php.tar.xz.asc "$PHP_ASC_URL"; \
|
||||
export GNUPGHOME="$(mktemp -d)"; \
|
||||
/tmp/scripts/receivePgpKeys.sh $GPG_KEYS; \
|
||||
gpg --batch --verify php.tar.xz.asc php.tar.xz; \
|
||||
command -v gpgconf > /dev/null && gpgconf --kill all; \
|
||||
rm -rf "$GNUPGHOME"; \
|
||||
fi; \
|
||||
\
|
||||
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $fetchDeps
|
||||
|
||||
COPY docker-php-source /usr/local/bin/
|
||||
RUN chmod +x /usr/local/bin/docker-php-source
|
||||
|
||||
RUN set -eux; \
|
||||
\
|
||||
savedAptMark="$(apt-mark showmanual)"; \
|
||||
apt-get update; \
|
||||
apt-get install -y --no-install-recommends \
|
||||
libcurl4-openssl-dev \
|
||||
libedit-dev \
|
||||
libsqlite3-dev \
|
||||
libssl-dev \
|
||||
libxml2-dev \
|
||||
zlib1g-dev \
|
||||
${PHP_EXTRA_BUILD_DEPS:-} \
|
||||
; \
|
||||
rm -rf /var/lib/apt/lists/*; \
|
||||
\
|
||||
export \
|
||||
CFLAGS="$PHP_CFLAGS" \
|
||||
CPPFLAGS="$PHP_CPPFLAGS" \
|
||||
LDFLAGS="$PHP_LDFLAGS" \
|
||||
; \
|
||||
docker-php-source extract; \
|
||||
cd /usr/src/php; \
|
||||
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
|
||||
debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)"; \
|
||||
# https://bugs.php.net/bug.php?id=74125
|
||||
if [ ! -d /usr/include/curl ]; then \
|
||||
ln -sT "/usr/include/$debMultiarch/curl" /usr/local/include/curl; \
|
||||
fi; \
|
||||
./configure \
|
||||
--build="$gnuArch" \
|
||||
--with-config-file-path="$PHP_INI_DIR" \
|
||||
--with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \
|
||||
\
|
||||
# make sure invalid --configure-flags are fatal errors intead of just warnings
|
||||
--enable-option-checking=fatal \
|
||||
\
|
||||
# https://github.com/docker-library/php/issues/439
|
||||
--with-mhash \
|
||||
\
|
||||
# --enable-ftp is included here because ftp_ssl_connect() needs ftp to be compiled statically (see https://github.com/docker-library/php/issues/236)
|
||||
--enable-ftp \
|
||||
# --enable-mbstring is included here because otherwise there's no way to get pecl to use it properly (see https://github.com/docker-library/php/issues/195)
|
||||
--enable-mbstring \
|
||||
# --enable-mysqlnd is included here because it's harder to compile after the fact than extensions are (since it's a plugin for several extensions, not an extension in itself)
|
||||
--enable-mysqlnd \
|
||||
\
|
||||
--with-curl \
|
||||
--with-libedit \
|
||||
--with-openssl \
|
||||
--with-zlib \
|
||||
\
|
||||
# bundled pcre does not support JIT on s390x
|
||||
# https://manpages.debian.org/stretch/libpcre3-dev/pcrejit.3.en.html#AVAILABILITY_OF_JIT_SUPPORT
|
||||
$(test "$gnuArch" = 's390x-linux-gnu' && echo '--without-pcre-jit') \
|
||||
--with-libdir="lib/$debMultiarch" \
|
||||
\
|
||||
${PHP_EXTRA_CONFIGURE_ARGS:-} \
|
||||
; \
|
||||
make -j "$(nproc)"; \
|
||||
make install; \
|
||||
find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; \
|
||||
make clean; \
|
||||
\
|
||||
# https://github.com/docker-library/php/issues/692 (copy default example "php.ini" files somewhere easily discoverable)
|
||||
cp -v php.ini-* "$PHP_INI_DIR/"; \
|
||||
\
|
||||
cd /; \
|
||||
docker-php-source delete; \
|
||||
\
|
||||
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
|
||||
apt-mark auto '.*' > /dev/null; \
|
||||
[ -z "$savedAptMark" ] || apt-mark manual $savedAptMark; \
|
||||
find /usr/local -type f -executable -exec ldd '{}' ';' \
|
||||
| awk '/=>/ { print $(NF-1) }' \
|
||||
| sort -u \
|
||||
| xargs -r dpkg-query --search \
|
||||
| cut -d: -f1 \
|
||||
| sort -u \
|
||||
| xargs -r apt-mark manual \
|
||||
; \
|
||||
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
|
||||
\
|
||||
php --version; \
|
||||
\
|
||||
# https://github.com/docker-library/php/issues/443
|
||||
pecl update-channels; \
|
||||
rm -rf /tmp/pear ~/.pearrc
|
||||
|
||||
COPY docker-php-ext-* docker-php-entrypoint /usr/local/bin/
|
||||
RUN chmod +x /usr/local/bin/docker-*
|
||||
|
||||
RUN set -eux \
|
||||
&& docker-php-ext-install mcrypt \
|
||||
&& docker-php-ext-enable mcrypt
|
||||
|
||||
ENTRYPOINT ["docker-php-entrypoint"]
|
||||
##<autogenerated>##
|
||||
COPY apache2-foreground /usr/local/bin/
|
||||
RUN chmod +x /usr/local/bin/apache2-foreground
|
||||
WORKDIR /var/www/html
|
||||
|
||||
EXPOSE 80
|
||||
CMD ["apache2-foreground"]
|
||||
##</autogenerated>##
|
|
@ -0,0 +1,40 @@
|
|||
#!/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_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 "$@"
|
|
@ -0,0 +1,9 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
# first arg is `-f` or `--some-option`
|
||||
if [ "${1#-}" != "$1" ]; then
|
||||
set -- apache2-foreground "$@"
|
||||
fi
|
||||
|
||||
exec "$@"
|
|
@ -0,0 +1,69 @@
|
|||
#!/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 ext-name [configure flags]"
|
||||
echo " ie: $0 gd --with-jpeg-dir=/usr/local/something"
|
||||
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
|
||||
echo
|
||||
echo 'Some of the above modules are already compiled into PHP; please check'
|
||||
echo 'the output of "php -i" to see which modules are already loaded.'
|
||||
}
|
||||
|
||||
ext="$1"
|
||||
if [ -z "$ext" ] || [ ! -d "$ext" ]; then
|
||||
usage >&2
|
||||
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
|
||||
|
||||
if command -v dpkg-architecture > /dev/null; then
|
||||
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"
|
||||
set -- --build="$gnuArch" "$@"
|
||||
fi
|
||||
|
||||
cd "$ext"
|
||||
phpize
|
||||
./configure "$@"
|
|
@ -0,0 +1,114 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
extDir="$(php -r 'echo ini_get("extension_dir");')"
|
||||
cd "$extDir"
|
||||
|
||||
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:'
|
||||
find -maxdepth 1 \
|
||||
-type f \
|
||||
-name '*.so' \
|
||||
-exec basename '{}' ';' \
|
||||
| sort \
|
||||
| xargs
|
||||
echo
|
||||
echo 'Some of the above modules are already compiled into PHP; please check'
|
||||
echo 'the output of "php -i" to see which modules are already loaded.'
|
||||
}
|
||||
|
||||
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: '$module' does not exist"
|
||||
echo >&2
|
||||
usage >&2
|
||||
exit 1
|
||||
fi
|
||||
modules="$modules $module"
|
||||
done
|
||||
|
||||
if [ -z "$modules" ]; 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" ] \
|
||||
&& ! apk info --installed .phpize-deps > /dev/null \
|
||||
&& ! apk info --installed .phpize-deps-configure > /dev/null \
|
||||
; then
|
||||
apk add --no-cache --virtual '.docker-php-ext-enable-deps' binutils
|
||||
apkDel='.docker-php-ext-enable-deps'
|
||||
fi
|
||||
fi
|
||||
|
||||
for module in $modules; do
|
||||
if readelf --wide --syms "$module" | grep -q ' zend_extension_entry$'; then
|
||||
# https://wiki.php.net/internals/extensions#loading_zend_extensions
|
||||
absModule="$(readlink -f "$module")"
|
||||
line="zend_extension=$absModule"
|
||||
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="$PHP_INI_DIR/conf.d/${iniName:-"docker-php-ext-$ext.ini"}"
|
||||
if ! grep -q "$line" "$ini" 2>/dev/null; then
|
||||
echo "$line" >> "$ini"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$pm" = 'apk' ] && [ -n "$apkDel" ]; then
|
||||
apk del $apkDel
|
||||
fi
|
|
@ -0,0 +1,122 @@
|
|||
#!/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
|
||||
echo
|
||||
echo 'Some of the above modules are already compiled into PHP; please check'
|
||||
echo 'the output of "php -i" to see which modules are already loaded.'
|
||||
}
|
||||
|
||||
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
|
|
@ -0,0 +1,34 @@
|
|||
#!/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 "$dir"
|
||||
;;
|
||||
|
||||
*)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
|
@ -0,0 +1,270 @@
|
|||
# From https://github.com/docker-library/php.git
|
||||
FROM php-run-base
|
||||
|
||||
# do NOT merge this content with above line because the
|
||||
# above line is shared across all php images
|
||||
# Install the Microsoft SQL Server PDO driver on supported versions only.
|
||||
# - https://docs.microsoft.com/en-us/sql/connect/php/installation-tutorial-linux-mac
|
||||
# - https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server
|
||||
RUN set -eux \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
gnupg2 \
|
||||
apt-transport-https \
|
||||
&& curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
|
||||
&& curl https://packages.microsoft.com/config/debian/9/prod.list > /etc/apt/sources.list.d/mssql-release.list \
|
||||
&& apt-get update \
|
||||
&& ACCEPT_EULA=Y apt-get install -y msodbcsql17 unixodbc-dev
|
||||
|
||||
ENV PHP_INI_DIR /usr/local/etc/php
|
||||
RUN set -eux; \
|
||||
mkdir -p "$PHP_INI_DIR/conf.d"; \
|
||||
# allow running as an arbitrary user (https://github.com/docker-library/php/issues/743)
|
||||
[ ! -d /var/www/html ]; \
|
||||
mkdir -p /var/www/html; \
|
||||
chown www-data:www-data /var/www/html; \
|
||||
chmod 777 /var/www/html
|
||||
|
||||
##<autogenerated>##
|
||||
ENV APACHE_CONFDIR /etc/apache2
|
||||
ENV APACHE_ENVVARS $APACHE_CONFDIR/envvars
|
||||
|
||||
RUN set -eux; \
|
||||
apt-get update; \
|
||||
apt-get install -y --no-install-recommends apache2; \
|
||||
rm -rf /var/lib/apt/lists/*; \
|
||||
\
|
||||
# generically convert lines like
|
||||
# export APACHE_RUN_USER=www-data
|
||||
# into
|
||||
# : ${APACHE_RUN_USER:=www-data}
|
||||
# export APACHE_RUN_USER
|
||||
# so that they can be overridden at runtime ("-e APACHE_RUN_USER=...")
|
||||
sed -ri 's/^export ([^=]+)=(.*)$/: ${\1:=\2}\nexport \1/' "$APACHE_ENVVARS"; \
|
||||
\
|
||||
# setup directories and permissions
|
||||
. "$APACHE_ENVVARS"; \
|
||||
for dir in \
|
||||
"$APACHE_LOCK_DIR" \
|
||||
"$APACHE_RUN_DIR" \
|
||||
"$APACHE_LOG_DIR" \
|
||||
; do \
|
||||
rm -rvf "$dir"; \
|
||||
mkdir -p "$dir"; \
|
||||
chown "$APACHE_RUN_USER:$APACHE_RUN_GROUP" "$dir"; \
|
||||
# allow running as an arbitrary user (https://github.com/docker-library/php/issues/743)
|
||||
chmod 777 "$dir"; \
|
||||
done; \
|
||||
\
|
||||
# delete the "index.html" that installing Apache drops in here
|
||||
rm -rvf /var/www/html/*; \
|
||||
\
|
||||
# logs should go to stdout / stderr
|
||||
ln -sfT /dev/stderr "$APACHE_LOG_DIR/error.log"; \
|
||||
ln -sfT /dev/stdout "$APACHE_LOG_DIR/access.log"; \
|
||||
ln -sfT /dev/stdout "$APACHE_LOG_DIR/other_vhosts_access.log"; \
|
||||
chown -R --no-dereference "$APACHE_RUN_USER:$APACHE_RUN_GROUP" "$APACHE_LOG_DIR"
|
||||
|
||||
# Apache + PHP requires preforking Apache for best results
|
||||
RUN a2dismod mpm_event && a2enmod mpm_prefork
|
||||
|
||||
# PHP files should be handled by PHP, and should be preferred over any other file type
|
||||
RUN { \
|
||||
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 "$APACHE_CONFDIR/conf-available/docker-php.conf" \
|
||||
&& a2enconf docker-php
|
||||
|
||||
ENV PHP_EXTRA_BUILD_DEPS apache2-dev
|
||||
ENV PHP_EXTRA_CONFIGURE_ARGS --with-apxs2 --disable-cgi
|
||||
##</autogenerated>##
|
||||
|
||||
# Apply stack smash protection to functions using local buffers and alloca()
|
||||
# Make PHP's main executable position-independent (improves ASLR security mechanism, and has no performance impact on x86_64)
|
||||
# Enable optimization (-O2)
|
||||
# Enable linker optimization (this sorts the hash buckets to improve cache locality, and is non-default)
|
||||
# Adds GNU HASH segments to generated executables (this is used if present, and is much faster than sysv hash; in this configuration, sysv hash is also generated)
|
||||
# https://github.com/docker-library/php/issues/272
|
||||
# -D_LARGEFILE_SOURCE and -D_FILE_OFFSET_BITS=64 (https://www.php.net/manual/en/intro.filesystem.php)
|
||||
ENV PHP_CFLAGS="-fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
|
||||
ENV PHP_CPPFLAGS="$PHP_CFLAGS"
|
||||
ENV PHP_LDFLAGS="-Wl,-O1 -Wl,--hash-style=both -pie"
|
||||
|
||||
ENV GPG_KEYS 1729F83938DA44E27BA0F4D3DBDB397470D12172 B1B44D8F021E4E2D6021E995DC9FF8D3EE5AF27F
|
||||
|
||||
ENV PHP_VERSION 7.2.24
|
||||
ENV PHP_URL="https://www.php.net/get/php-7.2.24.tar.xz/from/this/mirror" PHP_ASC_URL="https://www.php.net/get/php-7.2.24.tar.xz.asc/from/this/mirror"
|
||||
ENV PHP_SHA256="a6a6cc03388060aa5f8f9e45799b72bce1c7ed7b9d7b3f1187787202aad91d25" PHP_MD5=""
|
||||
|
||||
RUN set -eux; \
|
||||
\
|
||||
savedAptMark="$(apt-mark showmanual)"; \
|
||||
apt-get update; \
|
||||
apt-get install -y --no-install-recommends gnupg dirmngr; \
|
||||
rm -rf /var/lib/apt/lists/*; \
|
||||
\
|
||||
mkdir -p /usr/src; \
|
||||
cd /usr/src; \
|
||||
\
|
||||
curl -fsSL -o php.tar.xz "$PHP_URL"; \
|
||||
\
|
||||
if [ -n "$PHP_SHA256" ]; then \
|
||||
echo "$PHP_SHA256 *php.tar.xz" | sha256sum -c -; \
|
||||
fi; \
|
||||
if [ -n "$PHP_MD5" ]; then \
|
||||
echo "$PHP_MD5 *php.tar.xz" | md5sum -c -; \
|
||||
fi; \
|
||||
\
|
||||
if [ -n "$PHP_ASC_URL" ]; then \
|
||||
curl -fsSL -o php.tar.xz.asc "$PHP_ASC_URL"; \
|
||||
export GNUPGHOME="$(mktemp -d)"; \
|
||||
/tmp/scripts/receivePgpKeys.sh $GPG_KEYS; \
|
||||
gpg --batch --verify php.tar.xz.asc php.tar.xz; \
|
||||
gpgconf --kill all; \
|
||||
rm -rf "$GNUPGHOME"; \
|
||||
fi; \
|
||||
\
|
||||
apt-mark auto '.*' > /dev/null; \
|
||||
apt-mark manual $savedAptMark > /dev/null; \
|
||||
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false
|
||||
|
||||
COPY docker-php-source /usr/local/bin/
|
||||
RUN chmod +x /usr/local/bin/docker-php-source
|
||||
|
||||
RUN set -eux; \
|
||||
\
|
||||
savedAptMark="$(apt-mark showmanual)"; \
|
||||
##<argon2-stretch>##
|
||||
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; \
|
||||
##</argon2-stretch>##
|
||||
apt-get update; \
|
||||
apt-get install -y --no-install-recommends \
|
||||
libargon2-dev \
|
||||
libcurl4-openssl-dev \
|
||||
libedit-dev \
|
||||
libsodium-dev \
|
||||
libsqlite3-dev \
|
||||
libssl-dev \
|
||||
libxml2-dev \
|
||||
zlib1g-dev \
|
||||
${PHP_EXTRA_BUILD_DEPS:-} \
|
||||
; \
|
||||
rm -rf /var/lib/apt/lists/*; \
|
||||
\
|
||||
export \
|
||||
CFLAGS="$PHP_CFLAGS" \
|
||||
CPPFLAGS="$PHP_CPPFLAGS" \
|
||||
LDFLAGS="$PHP_LDFLAGS" \
|
||||
; \
|
||||
docker-php-source extract; \
|
||||
cd /usr/src/php; \
|
||||
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
|
||||
debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)"; \
|
||||
# https://bugs.php.net/bug.php?id=74125
|
||||
if [ ! -d /usr/include/curl ]; then \
|
||||
ln -sT "/usr/include/$debMultiarch/curl" /usr/local/include/curl; \
|
||||
fi; \
|
||||
./configure \
|
||||
--build="$gnuArch" \
|
||||
--with-config-file-path="$PHP_INI_DIR" \
|
||||
--with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \
|
||||
\
|
||||
# make sure invalid --configure-flags are fatal errors intead of just warnings
|
||||
--enable-option-checking=fatal \
|
||||
\
|
||||
# https://github.com/docker-library/php/issues/439
|
||||
--with-mhash \
|
||||
\
|
||||
# --enable-ftp is included here because ftp_ssl_connect() needs ftp to be compiled statically (see https://github.com/docker-library/php/issues/236)
|
||||
--enable-ftp \
|
||||
# --enable-mbstring is included here because otherwise there's no way to get pecl to use it properly (see https://github.com/docker-library/php/issues/195)
|
||||
--enable-mbstring \
|
||||
# --enable-mysqlnd is included here because it's harder to compile after the fact than extensions are (since it's a plugin for several extensions, not an extension in itself)
|
||||
--enable-mysqlnd \
|
||||
# https://wiki.php.net/rfc/argon2_password_hash (7.2+)
|
||||
--with-password-argon2 \
|
||||
# https://wiki.php.net/rfc/libsodium
|
||||
--with-sodium=shared \
|
||||
# always build against system sqlite3 (https://github.com/php/php-src/commit/6083a387a81dbbd66d6316a3a12a63f06d5f7109)
|
||||
--with-pdo-sqlite=/usr \
|
||||
--with-sqlite3=/usr \
|
||||
\
|
||||
--with-curl \
|
||||
--with-libedit \
|
||||
--with-openssl \
|
||||
--with-zlib \
|
||||
\
|
||||
# bundled pcre does not support JIT on s390x
|
||||
# https://manpages.debian.org/stretch/libpcre3-dev/pcrejit.3.en.html#AVAILABILITY_OF_JIT_SUPPORT
|
||||
$(test "$gnuArch" = 's390x-linux-gnu' && echo '--without-pcre-jit') \
|
||||
--with-libdir="lib/$debMultiarch" \
|
||||
\
|
||||
${PHP_EXTRA_CONFIGURE_ARGS:-} \
|
||||
; \
|
||||
make -j "$(nproc)"; \
|
||||
find -type f -name '*.a' -delete; \
|
||||
make install; \
|
||||
find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; \
|
||||
make clean; \
|
||||
\
|
||||
# https://github.com/docker-library/php/issues/692 (copy default example "php.ini" files somewhere easily discoverable)
|
||||
cp -v php.ini-* "$PHP_INI_DIR/"; \
|
||||
\
|
||||
cd /; \
|
||||
docker-php-source delete; \
|
||||
\
|
||||
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
|
||||
apt-mark auto '.*' > /dev/null; \
|
||||
[ -z "$savedAptMark" ] || apt-mark manual $savedAptMark; \
|
||||
find /usr/local -type f -executable -exec ldd '{}' ';' \
|
||||
| awk '/=>/ { print $(NF-1) }' \
|
||||
| sort -u \
|
||||
| xargs -r dpkg-query --search \
|
||||
| cut -d: -f1 \
|
||||
| sort -u \
|
||||
| xargs -r apt-mark manual \
|
||||
; \
|
||||
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
|
||||
\
|
||||
# update pecl channel definitions https://github.com/docker-library/php/issues/443
|
||||
pecl update-channels; \
|
||||
rm -rf /tmp/pear ~/.pearrc; \
|
||||
# smoke test
|
||||
php --version
|
||||
|
||||
COPY docker-php-ext-* docker-php-entrypoint /usr/local/bin/
|
||||
RUN chmod +x /usr/local/bin/docker-php-*
|
||||
|
||||
# sodium was built as a shared module (so that it can be replaced later if so desired), so let's enable it too (https://github.com/docker-library/php/issues/598)
|
||||
RUN docker-php-ext-enable sodium
|
||||
|
||||
ENTRYPOINT ["docker-php-entrypoint"]
|
||||
##<autogenerated>##
|
||||
# https://httpd.apache.org/docs/2.4/stopping.html#gracefulstop
|
||||
STOPSIGNAL WINCH
|
||||
|
||||
COPY apache2-foreground /usr/local/bin/
|
||||
RUN chmod +x /usr/local/bin/apache2-foreground
|
||||
WORKDIR /var/www/html
|
||||
|
||||
EXPOSE 80
|
||||
CMD ["apache2-foreground"]
|
||||
##</autogenerated>##
|
|
@ -0,0 +1,40 @@
|
|||
#!/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_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 "$@"
|
|
@ -0,0 +1,9 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
# first arg is `-f` or `--some-option`
|
||||
if [ "${1#-}" != "$1" ]; then
|
||||
set -- apache2-foreground "$@"
|
||||
fi
|
||||
|
||||
exec "$@"
|
|
@ -0,0 +1,69 @@
|
|||
#!/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 ext-name [configure flags]"
|
||||
echo " ie: $0 gd --with-jpeg-dir=/usr/local/something"
|
||||
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
|
||||
echo
|
||||
echo 'Some of the above modules are already compiled into PHP; please check'
|
||||
echo 'the output of "php -i" to see which modules are already loaded.'
|
||||
}
|
||||
|
||||
ext="$1"
|
||||
if [ -z "$ext" ] || [ ! -d "$ext" ]; then
|
||||
usage >&2
|
||||
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
|
||||
|
||||
if command -v dpkg-architecture > /dev/null; then
|
||||
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"
|
||||
set -- --build="$gnuArch" "$@"
|
||||
fi
|
||||
|
||||
cd "$ext"
|
||||
phpize
|
||||
./configure "$@"
|
|
@ -0,0 +1,114 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
extDir="$(php -d 'display_errors=stderr' -r 'echo ini_get("extension_dir");')"
|
||||
cd "$extDir"
|
||||
|
||||
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:'
|
||||
find -maxdepth 1 \
|
||||
-type f \
|
||||
-name '*.so' \
|
||||
-exec basename '{}' ';' \
|
||||
| sort \
|
||||
| xargs
|
||||
echo
|
||||
echo 'Some of the above modules are already compiled into PHP; please check'
|
||||
echo 'the output of "php -i" to see which modules are already loaded.'
|
||||
}
|
||||
|
||||
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: '$module' does not exist"
|
||||
echo >&2
|
||||
usage >&2
|
||||
exit 1
|
||||
fi
|
||||
modules="$modules $module"
|
||||
done
|
||||
|
||||
if [ -z "$modules" ]; 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" ] \
|
||||
&& ! apk info --installed .phpize-deps > /dev/null \
|
||||
&& ! apk info --installed .phpize-deps-configure > /dev/null \
|
||||
; then
|
||||
apk add --no-cache --virtual '.docker-php-ext-enable-deps' binutils
|
||||
apkDel='.docker-php-ext-enable-deps'
|
||||
fi
|
||||
fi
|
||||
|
||||
for module in $modules; do
|
||||
if readelf --wide --syms "$module" | grep -q ' zend_extension_entry$'; then
|
||||
# https://wiki.php.net/internals/extensions#loading_zend_extensions
|
||||
absModule="$(readlink -f "$module")"
|
||||
line="zend_extension=$absModule"
|
||||
else
|
||||
line="extension=$module"
|
||||
fi
|
||||
|
||||
ext="$(basename "$module")"
|
||||
ext="${ext%.*}"
|
||||
if php -d 'display_errors=stderr' -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="$PHP_INI_DIR/conf.d/${iniName:-"docker-php-ext-$ext.ini"}"
|
||||
if ! grep -q "$line" "$ini" 2>/dev/null; then
|
||||
echo "$line" >> "$ini"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$pm" = 'apk' ] && [ -n "$apkDel" ]; then
|
||||
apk del --no-network $apkDel
|
||||
fi
|
|
@ -0,0 +1,122 @@
|
|||
#!/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
|
||||
echo
|
||||
echo 'Some of the above modules are already compiled into PHP; please check'
|
||||
echo 'the output of "php -i" to see which modules are already loaded.'
|
||||
}
|
||||
|
||||
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 --no-network $apkDel
|
||||
fi
|
||||
|
||||
if [ -e /usr/src/php/.docker-delete-me ]; then
|
||||
docker-php-source delete
|
||||
fi
|
|
@ -0,0 +1,34 @@
|
|||
#!/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 "$dir"
|
||||
;;
|
||||
|
||||
*)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
|
@ -0,0 +1,270 @@
|
|||
# From https://github.com/docker-library/php.git
|
||||
FROM php-run-base
|
||||
|
||||
# do NOT merge this content with above line because the
|
||||
# above line is shared across all php images
|
||||
# Install the Microsoft SQL Server PDO driver on supported versions only.
|
||||
# - https://docs.microsoft.com/en-us/sql/connect/php/installation-tutorial-linux-mac
|
||||
# - https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server
|
||||
RUN set -eux \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
gnupg2 \
|
||||
apt-transport-https \
|
||||
&& curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
|
||||
&& curl https://packages.microsoft.com/config/debian/9/prod.list > /etc/apt/sources.list.d/mssql-release.list \
|
||||
&& apt-get update \
|
||||
&& ACCEPT_EULA=Y apt-get install -y msodbcsql17 unixodbc-dev
|
||||
|
||||
ENV PHP_INI_DIR /usr/local/etc/php
|
||||
RUN set -eux; \
|
||||
mkdir -p "$PHP_INI_DIR/conf.d"; \
|
||||
# allow running as an arbitrary user (https://github.com/docker-library/php/issues/743)
|
||||
[ ! -d /var/www/html ]; \
|
||||
mkdir -p /var/www/html; \
|
||||
chown www-data:www-data /var/www/html; \
|
||||
chmod 777 /var/www/html
|
||||
|
||||
##<autogenerated>##
|
||||
ENV APACHE_CONFDIR /etc/apache2
|
||||
ENV APACHE_ENVVARS $APACHE_CONFDIR/envvars
|
||||
|
||||
RUN set -eux; \
|
||||
apt-get update; \
|
||||
apt-get install -y --no-install-recommends apache2; \
|
||||
rm -rf /var/lib/apt/lists/*; \
|
||||
\
|
||||
# generically convert lines like
|
||||
# export APACHE_RUN_USER=www-data
|
||||
# into
|
||||
# : ${APACHE_RUN_USER:=www-data}
|
||||
# export APACHE_RUN_USER
|
||||
# so that they can be overridden at runtime ("-e APACHE_RUN_USER=...")
|
||||
sed -ri 's/^export ([^=]+)=(.*)$/: ${\1:=\2}\nexport \1/' "$APACHE_ENVVARS"; \
|
||||
\
|
||||
# setup directories and permissions
|
||||
. "$APACHE_ENVVARS"; \
|
||||
for dir in \
|
||||
"$APACHE_LOCK_DIR" \
|
||||
"$APACHE_RUN_DIR" \
|
||||
"$APACHE_LOG_DIR" \
|
||||
; do \
|
||||
rm -rvf "$dir"; \
|
||||
mkdir -p "$dir"; \
|
||||
chown "$APACHE_RUN_USER:$APACHE_RUN_GROUP" "$dir"; \
|
||||
# allow running as an arbitrary user (https://github.com/docker-library/php/issues/743)
|
||||
chmod 777 "$dir"; \
|
||||
done; \
|
||||
\
|
||||
# delete the "index.html" that installing Apache drops in here
|
||||
rm -rvf /var/www/html/*; \
|
||||
\
|
||||
# logs should go to stdout / stderr
|
||||
ln -sfT /dev/stderr "$APACHE_LOG_DIR/error.log"; \
|
||||
ln -sfT /dev/stdout "$APACHE_LOG_DIR/access.log"; \
|
||||
ln -sfT /dev/stdout "$APACHE_LOG_DIR/other_vhosts_access.log"; \
|
||||
chown -R --no-dereference "$APACHE_RUN_USER:$APACHE_RUN_GROUP" "$APACHE_LOG_DIR"
|
||||
|
||||
# Apache + PHP requires preforking Apache for best results
|
||||
RUN a2dismod mpm_event && a2enmod mpm_prefork
|
||||
|
||||
# PHP files should be handled by PHP, and should be preferred over any other file type
|
||||
RUN { \
|
||||
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 "$APACHE_CONFDIR/conf-available/docker-php.conf" \
|
||||
&& a2enconf docker-php
|
||||
|
||||
ENV PHP_EXTRA_BUILD_DEPS apache2-dev
|
||||
ENV PHP_EXTRA_CONFIGURE_ARGS --with-apxs2 --disable-cgi
|
||||
##</autogenerated>##
|
||||
|
||||
# Apply stack smash protection to functions using local buffers and alloca()
|
||||
# Make PHP's main executable position-independent (improves ASLR security mechanism, and has no performance impact on x86_64)
|
||||
# Enable optimization (-O2)
|
||||
# Enable linker optimization (this sorts the hash buckets to improve cache locality, and is non-default)
|
||||
# Adds GNU HASH segments to generated executables (this is used if present, and is much faster than sysv hash; in this configuration, sysv hash is also generated)
|
||||
# https://github.com/docker-library/php/issues/272
|
||||
# -D_LARGEFILE_SOURCE and -D_FILE_OFFSET_BITS=64 (https://www.php.net/manual/en/intro.filesystem.php)
|
||||
ENV PHP_CFLAGS="-fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
|
||||
ENV PHP_CPPFLAGS="$PHP_CFLAGS"
|
||||
ENV PHP_LDFLAGS="-Wl,-O1 -Wl,--hash-style=both -pie"
|
||||
|
||||
ENV GPG_KEYS CBAF69F173A0FEA4B537F470D66C9593118BCCB6 F38252826ACD957EF380D39F2F7956BC5DA04B5D
|
||||
|
||||
ENV PHP_VERSION 7.3.11
|
||||
ENV PHP_URL="https://www.php.net/get/php-7.3.11.tar.xz/from/this/mirror" PHP_ASC_URL="https://www.php.net/get/php-7.3.11.tar.xz.asc/from/this/mirror"
|
||||
ENV PHP_SHA256="657cf6464bac28e9490c59c07a2cf7bb76c200f09cfadf6e44ea64e95fa01021" PHP_MD5=""
|
||||
|
||||
RUN set -eux; \
|
||||
\
|
||||
savedAptMark="$(apt-mark showmanual)"; \
|
||||
apt-get update; \
|
||||
apt-get install -y --no-install-recommends gnupg dirmngr; \
|
||||
rm -rf /var/lib/apt/lists/*; \
|
||||
\
|
||||
mkdir -p /usr/src; \
|
||||
cd /usr/src; \
|
||||
\
|
||||
curl -fsSL -o php.tar.xz "$PHP_URL"; \
|
||||
\
|
||||
if [ -n "$PHP_SHA256" ]; then \
|
||||
echo "$PHP_SHA256 *php.tar.xz" | sha256sum -c -; \
|
||||
fi; \
|
||||
if [ -n "$PHP_MD5" ]; then \
|
||||
echo "$PHP_MD5 *php.tar.xz" | md5sum -c -; \
|
||||
fi; \
|
||||
\
|
||||
if [ -n "$PHP_ASC_URL" ]; then \
|
||||
curl -fsSL -o php.tar.xz.asc "$PHP_ASC_URL"; \
|
||||
export GNUPGHOME="$(mktemp -d)"; \
|
||||
/tmp/scripts/receivePgpKeys.sh $GPG_KEYS; \
|
||||
gpg --batch --verify php.tar.xz.asc php.tar.xz; \
|
||||
gpgconf --kill all; \
|
||||
rm -rf "$GNUPGHOME"; \
|
||||
fi; \
|
||||
\
|
||||
apt-mark auto '.*' > /dev/null; \
|
||||
apt-mark manual $savedAptMark > /dev/null; \
|
||||
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false
|
||||
|
||||
COPY docker-php-source /usr/local/bin/docker-php-source
|
||||
RUN chmod +x /usr/local/bin/docker-php-source
|
||||
|
||||
RUN set -eux; \
|
||||
\
|
||||
savedAptMark="$(apt-mark showmanual)"; \
|
||||
##<argon2-stretch>##
|
||||
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; \
|
||||
##</argon2-stretch>##
|
||||
apt-get update; \
|
||||
apt-get install -y --no-install-recommends \
|
||||
libargon2-dev \
|
||||
libcurl4-openssl-dev \
|
||||
libedit-dev \
|
||||
libsodium-dev \
|
||||
libsqlite3-dev \
|
||||
libssl-dev \
|
||||
libxml2-dev \
|
||||
zlib1g-dev \
|
||||
${PHP_EXTRA_BUILD_DEPS:-} \
|
||||
; \
|
||||
rm -rf /var/lib/apt/lists/*; \
|
||||
\
|
||||
export \
|
||||
CFLAGS="$PHP_CFLAGS" \
|
||||
CPPFLAGS="$PHP_CPPFLAGS" \
|
||||
LDFLAGS="$PHP_LDFLAGS" \
|
||||
; \
|
||||
docker-php-source extract; \
|
||||
cd /usr/src/php; \
|
||||
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
|
||||
debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)"; \
|
||||
# https://bugs.php.net/bug.php?id=74125
|
||||
if [ ! -d /usr/include/curl ]; then \
|
||||
ln -sT "/usr/include/$debMultiarch/curl" /usr/local/include/curl; \
|
||||
fi; \
|
||||
./configure \
|
||||
--build="$gnuArch" \
|
||||
--with-config-file-path="$PHP_INI_DIR" \
|
||||
--with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \
|
||||
\
|
||||
# make sure invalid --configure-flags are fatal errors intead of just warnings
|
||||
--enable-option-checking=fatal \
|
||||
\
|
||||
# https://github.com/docker-library/php/issues/439
|
||||
--with-mhash \
|
||||
\
|
||||
# --enable-ftp is included here because ftp_ssl_connect() needs ftp to be compiled statically (see https://github.com/docker-library/php/issues/236)
|
||||
--enable-ftp \
|
||||
# --enable-mbstring is included here because otherwise there's no way to get pecl to use it properly (see https://github.com/docker-library/php/issues/195)
|
||||
--enable-mbstring \
|
||||
# --enable-mysqlnd is included here because it's harder to compile after the fact than extensions are (since it's a plugin for several extensions, not an extension in itself)
|
||||
--enable-mysqlnd \
|
||||
# https://wiki.php.net/rfc/argon2_password_hash (7.2+)
|
||||
--with-password-argon2 \
|
||||
# https://wiki.php.net/rfc/libsodium
|
||||
--with-sodium=shared \
|
||||
# always build against system sqlite3 (https://github.com/php/php-src/commit/6083a387a81dbbd66d6316a3a12a63f06d5f7109)
|
||||
--with-pdo-sqlite=/usr \
|
||||
--with-sqlite3=/usr \
|
||||
\
|
||||
--with-curl \
|
||||
--with-libedit \
|
||||
--with-openssl \
|
||||
--with-zlib \
|
||||
\
|
||||
# bundled pcre does not support JIT on s390x
|
||||
# https://manpages.debian.org/stretch/libpcre3-dev/pcrejit.3.en.html#AVAILABILITY_OF_JIT_SUPPORT
|
||||
$(test "$gnuArch" = 's390x-linux-gnu' && echo '--without-pcre-jit') \
|
||||
--with-libdir="lib/$debMultiarch" \
|
||||
\
|
||||
${PHP_EXTRA_CONFIGURE_ARGS:-} \
|
||||
; \
|
||||
make -j "$(nproc)"; \
|
||||
find -type f -name '*.a' -delete; \
|
||||
make install; \
|
||||
find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; \
|
||||
make clean; \
|
||||
\
|
||||
# https://github.com/docker-library/php/issues/692 (copy default example "php.ini" files somewhere easily discoverable)
|
||||
cp -v php.ini-* "$PHP_INI_DIR/"; \
|
||||
\
|
||||
cd /; \
|
||||
docker-php-source delete; \
|
||||
\
|
||||
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
|
||||
apt-mark auto '.*' > /dev/null; \
|
||||
[ -z "$savedAptMark" ] || apt-mark manual $savedAptMark; \
|
||||
find /usr/local -type f -executable -exec ldd '{}' ';' \
|
||||
| awk '/=>/ { print $(NF-1) }' \
|
||||
| sort -u \
|
||||
| xargs -r dpkg-query --search \
|
||||
| cut -d: -f1 \
|
||||
| sort -u \
|
||||
| xargs -r apt-mark manual \
|
||||
; \
|
||||
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
|
||||
\
|
||||
# update pecl channel definitions https://github.com/docker-library/php/issues/443
|
||||
pecl update-channels; \
|
||||
rm -rf /tmp/pear ~/.pearrc; \
|
||||
# smoke test
|
||||
php --version
|
||||
|
||||
COPY docker-php-ext-* docker-php-entrypoint /usr/local/bin/
|
||||
RUN chmod +x /usr/local/bin/docker-*
|
||||
|
||||
# sodium was built as a shared module (so that it can be replaced later if so desired), so let's enable it too (https://github.com/docker-library/php/issues/598)
|
||||
RUN docker-php-ext-enable sodium
|
||||
|
||||
ENTRYPOINT ["docker-php-entrypoint"]
|
||||
##<autogenerated>##
|
||||
# https://httpd.apache.org/docs/2.4/stopping.html#gracefulstop
|
||||
STOPSIGNAL WINCH
|
||||
|
||||
COPY apache2-foreground /usr/local/bin/
|
||||
RUN chmod +x /usr/local/bin/apache2-foreground
|
||||
WORKDIR /var/www/html
|
||||
|
||||
EXPOSE 80
|
||||
CMD ["apache2-foreground"]
|
||||
##</autogenerated>##
|
|
@ -0,0 +1,40 @@
|
|||
#!/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_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 "$@"
|
|
@ -0,0 +1,9 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
# first arg is `-f` or `--some-option`
|
||||
if [ "${1#-}" != "$1" ]; then
|
||||
set -- apache2-foreground "$@"
|
||||
fi
|
||||
|
||||
exec "$@"
|
|
@ -0,0 +1,69 @@
|
|||
#!/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 ext-name [configure flags]"
|
||||
echo " ie: $0 gd --with-jpeg-dir=/usr/local/something"
|
||||
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
|
||||
echo
|
||||
echo 'Some of the above modules are already compiled into PHP; please check'
|
||||
echo 'the output of "php -i" to see which modules are already loaded.'
|
||||
}
|
||||
|
||||
ext="$1"
|
||||
if [ -z "$ext" ] || [ ! -d "$ext" ]; then
|
||||
usage >&2
|
||||
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
|
||||
|
||||
if command -v dpkg-architecture > /dev/null; then
|
||||
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"
|
||||
set -- --build="$gnuArch" "$@"
|
||||
fi
|
||||
|
||||
cd "$ext"
|
||||
phpize
|
||||
./configure "$@"
|
|
@ -0,0 +1,114 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
extDir="$(php -d 'display_errors=stderr' -r 'echo ini_get("extension_dir");')"
|
||||
cd "$extDir"
|
||||
|
||||
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:'
|
||||
find -maxdepth 1 \
|
||||
-type f \
|
||||
-name '*.so' \
|
||||
-exec basename '{}' ';' \
|
||||
| sort \
|
||||
| xargs
|
||||
echo
|
||||
echo 'Some of the above modules are already compiled into PHP; please check'
|
||||
echo 'the output of "php -i" to see which modules are already loaded.'
|
||||
}
|
||||
|
||||
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: '$module' does not exist"
|
||||
echo >&2
|
||||
usage >&2
|
||||
exit 1
|
||||
fi
|
||||
modules="$modules $module"
|
||||
done
|
||||
|
||||
if [ -z "$modules" ]; 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" ] \
|
||||
&& ! apk info --installed .phpize-deps > /dev/null \
|
||||
&& ! apk info --installed .phpize-deps-configure > /dev/null \
|
||||
; then
|
||||
apk add --no-cache --virtual '.docker-php-ext-enable-deps' binutils
|
||||
apkDel='.docker-php-ext-enable-deps'
|
||||
fi
|
||||
fi
|
||||
|
||||
for module in $modules; do
|
||||
if readelf --wide --syms "$module" | grep -q ' zend_extension_entry$'; then
|
||||
# https://wiki.php.net/internals/extensions#loading_zend_extensions
|
||||
absModule="$(readlink -f "$module")"
|
||||
line="zend_extension=$absModule"
|
||||
else
|
||||
line="extension=$module"
|
||||
fi
|
||||
|
||||
ext="$(basename "$module")"
|
||||
ext="${ext%.*}"
|
||||
if php -d 'display_errors=stderr' -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="$PHP_INI_DIR/conf.d/${iniName:-"docker-php-ext-$ext.ini"}"
|
||||
if ! grep -q "$line" "$ini" 2>/dev/null; then
|
||||
echo "$line" >> "$ini"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$pm" = 'apk' ] && [ -n "$apkDel" ]; then
|
||||
apk del --no-network $apkDel
|
||||
fi
|
|
@ -0,0 +1,122 @@
|
|||
#!/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
|
||||
echo
|
||||
echo 'Some of the above modules are already compiled into PHP; please check'
|
||||
echo 'the output of "php -i" to see which modules are already loaded.'
|
||||
}
|
||||
|
||||
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 --no-network $apkDel
|
||||
fi
|
||||
|
||||
if [ -e /usr/src/php/.docker-delete-me ]; then
|
||||
docker-php-source delete
|
||||
fi
|
|
@ -0,0 +1,34 @@
|
|||
#!/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 "$dir"
|
||||
;;
|
||||
|
||||
*)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
|
@ -1,4 +1,4 @@
|
|||
FROM php:%PHP_BASE_IMAGE%
|
||||
FROM %PHP_BASE_IMAGE%
|
||||
SHELL ["/bin/bash", "-c"]
|
||||
ENV PHP_VERSION %PHP_VERSION%
|
||||
|
||||
|
@ -23,27 +23,6 @@ RUN echo -e 'ServerTokens Prod' >> /etc/apache2/apache2.conf
|
|||
# Install common PHP extensions
|
||||
RUN apt-get update \
|
||||
&& apt-get upgrade -y \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
libzip-dev \
|
||||
libpng-dev \
|
||||
libjpeg-dev \
|
||||
libpq-dev \
|
||||
libldap2-dev \
|
||||
libldb-dev \
|
||||
libicu-dev \
|
||||
libgmp-dev \
|
||||
libmagickwand-dev \
|
||||
libc-client-dev \
|
||||
libtidy-dev \
|
||||
libkrb5-dev \
|
||||
libxslt-dev \
|
||||
unixodbc-dev \
|
||||
openssh-server \
|
||||
vim \
|
||||
curl \
|
||||
wget \
|
||||
tcptraceroute \
|
||||
mariadb-client \
|
||||
&& ln -s /usr/lib/x86_64-linux-gnu/libldap.so /usr/lib/libldap.so \
|
||||
&& ln -s /usr/lib/x86_64-linux-gnu/liblber.so /usr/lib/liblber.so \
|
||||
&& ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h \
|
||||
|
@ -81,27 +60,15 @@ RUN apt-get update \
|
|||
xsl \
|
||||
&& pecl install imagick && docker-php-ext-enable imagick
|
||||
|
||||
# mcrypt was deprecated in 7.2 but exists in 5.6 and 7.0
|
||||
RUN set -eux; \
|
||||
if [[ $PHP_VERSION == 5.6.* || $PHP_VERSION == 7.0.* ]] ; then \
|
||||
apt-get update && apt-get install -y libmcrypt-dev \
|
||||
&& docker-php-ext-install mcrypt \
|
||||
&& docker-php-ext-enable mcrypt; \
|
||||
fi
|
||||
|
||||
# Install the Microsoft SQL Server PDO driver on supported versions only.
|
||||
# - https://docs.microsoft.com/en-us/sql/connect/php/installation-tutorial-linux-mac
|
||||
# - https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server
|
||||
RUN set -eux; \
|
||||
if [[ $PHP_VERSION == 7.1.* || $PHP_VERSION == 7.2.* || $PHP_VERSION == 7.3.* ]]; then \
|
||||
apt-get update && apt-get install -y gnupg2 apt-transport-https \
|
||||
&& curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
|
||||
&& curl https://packages.microsoft.com/config/debian/9/prod.list > /etc/apt/sources.list.d/mssql-release.list \
|
||||
&& apt-get update && ACCEPT_EULA=Y apt-get install -y msodbcsql17 unixodbc-dev \
|
||||
&& pecl install sqlsrv pdo_sqlsrv \
|
||||
pecl install sqlsrv pdo_sqlsrv \
|
||||
&& echo extension=pdo_sqlsrv.so >> `php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||"`/30-pdo_sqlsrv.ini \
|
||||
&& echo extension=sqlsrv.so >> `php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||"`/20-sqlsrv.ini; \
|
||||
fi
|
||||
fi
|
||||
|
||||
RUN { \
|
||||
echo 'opcache.memory_consumption=128'; \
|
||||
|
@ -129,8 +96,3 @@ RUN set -x \
|
|||
&& chmod +x ./configure \
|
||||
&& ./configure --with-unixODBC=shared,/usr \
|
||||
&& docker-php-ext-install odbc
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y \
|
||||
openssl \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
|
@ -0,0 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
declare -r __DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
|
||||
source "$__DIR/../../../build/__phpVersions.sh"
|
||||
declare -r VERSION_ARRAY=($PHP73_VERSION $PHP72_VERSION $PHP70_VERSION $PHP56_VERSION)
|
|
@ -0,0 +1,24 @@
|
|||
#!/bin/bash
|
||||
set -ex
|
||||
|
||||
declare -r CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
|
||||
source "$CURRENT_DIR/__versions.sh"
|
||||
|
||||
baseImage="php-run-base"
|
||||
echo
|
||||
echo "Buildig image '$baseImage'..."
|
||||
docker build -t $baseImage -f "$CURRENT_DIR/runbase.Dockerfile" .
|
||||
|
||||
for PHP_VERSION in "${VERSION_ARRAY[@]}"
|
||||
do
|
||||
IFS='.' read -ra SPLIT_VERSION <<< "$PHP_VERSION"
|
||||
VERSION_DIRECTORY="${SPLIT_VERSION[0]}.${SPLIT_VERSION[1]}"
|
||||
|
||||
PHP_IMAGE_NAME="php-$VERSION_DIRECTORY"
|
||||
cd "$CURRENT_DIR/$VERSION_DIRECTORY/"
|
||||
|
||||
echo
|
||||
echo "Building php image '$PHP_IMAGE_NAME'..."
|
||||
echo
|
||||
docker build -t $PHP_IMAGE_NAME -f "Dockerfile.$VERSION_DIRECTORY" .
|
||||
done
|
|
@ -7,20 +7,20 @@
|
|||
set -e
|
||||
|
||||
declare -r DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
|
||||
source "$DIR/__versions.sh"
|
||||
|
||||
declare -r DOCKERFILE_TEMPLATE="$DIR/Dockerfile.template"
|
||||
declare -r DOCKERFILE_BASE_TEMPLATE="$DIR/Dockerfile.base.template"
|
||||
declare -r IMAGE_NAME_PLACEHOLDER="%PHP_BASE_IMAGE%"
|
||||
declare -r PHP_VERSION_PLACEHOLDER="%PHP_VERSION%"
|
||||
. $DIR/../../../build/__phpVersions.sh
|
||||
declare -r VERSION_ARRAY=($PHP73_VERSION $PHP72_VERSION $PHP70_VERSION $PHP56_VERSION)
|
||||
declare -r RUNTIME_BASE_IMAGE_NAME_PLACEHOLDER="%RUNTIME_BASE_IMAGE_NAME%"
|
||||
|
||||
for PHP_VERSION in "${VERSION_ARRAY[@]}"
|
||||
do
|
||||
PHP_IMAGE_NAME="$PHP_VERSION-apache"
|
||||
|
||||
IFS='.' read -ra SPLIT_VERSION <<< "$PHP_VERSION"
|
||||
VERSION_DIRECTORY="${SPLIT_VERSION[0]}.${SPLIT_VERSION[1]}"
|
||||
|
||||
PHP_IMAGE_NAME="php-$VERSION_DIRECTORY"
|
||||
echo "Generating Dockerfile for image '$PHP_IMAGE_NAME' in directory '$VERSION_DIRECTORY'..."
|
||||
|
||||
mkdir -p "$DIR/$VERSION_DIRECTORY/"
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
FROM oryx-run-base
|
||||
|
||||
# prevent Debian's PHP packages from being installed
|
||||
# https://github.com/docker-library/php/pull/542
|
||||
RUN set -eux; \
|
||||
{ \
|
||||
echo 'Package: php*'; \
|
||||
echo 'Pin: release *'; \
|
||||
echo 'Pin-Priority: -1'; \
|
||||
} > /etc/apt/preferences.d/no-debian-php
|
||||
|
||||
# dependencies required for running "phpize"
|
||||
# (see persistent deps below)
|
||||
ENV PHPIZE_DEPS \
|
||||
autoconf \
|
||||
dpkg-dev \
|
||||
file \
|
||||
g++ \
|
||||
gcc \
|
||||
libc-dev \
|
||||
make \
|
||||
pkg-config \
|
||||
re2c
|
||||
|
||||
# persistent / runtime deps
|
||||
RUN set -eux; \
|
||||
apt-get update; \
|
||||
apt-get install -y --no-install-recommends \
|
||||
$PHPIZE_DEPS \
|
||||
ca-certificates \
|
||||
curl \
|
||||
xz-utils \
|
||||
libzip-dev \
|
||||
libpng-dev \
|
||||
libjpeg-dev \
|
||||
libpq-dev \
|
||||
libldap2-dev \
|
||||
libldb-dev \
|
||||
libicu-dev \
|
||||
libgmp-dev \
|
||||
libmagickwand-dev \
|
||||
libc-client-dev \
|
||||
libtidy-dev \
|
||||
libkrb5-dev \
|
||||
libxslt-dev \
|
||||
unixodbc-dev \
|
||||
openssh-server \
|
||||
vim \
|
||||
curl \
|
||||
wget \
|
||||
tcptraceroute \
|
||||
mariadb-client \
|
||||
openssl \
|
||||
; \
|
||||
rm -rf /var/lib/apt/lists/*
|
|
@ -4,7 +4,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.DotNetCore
|
|||
{
|
||||
public static class DotNetCoreRunTimeVersions
|
||||
{
|
||||
public const string DotNetCoreRuntimeBaseTag = "20191025.2";
|
||||
public const string DotNetCoreRuntimeBaseTag = "20191104.7";
|
||||
public const string NetCoreApp10 = "1.0.16";
|
||||
public const string NetCoreApp11 = "1.1.14";
|
||||
public const string NetCoreApp20 = "2.0.9";
|
||||
|
|
|
@ -4,8 +4,8 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Node
|
|||
{
|
||||
public static class NodeVersions
|
||||
{
|
||||
public const string NodeRuntimeBaseTag = "20191025.2";
|
||||
public const string YarnCacheBaseTag = "20191025.2";
|
||||
public const string NodeRuntimeBaseTag = "20191104.7";
|
||||
public const string YarnCacheBaseTag = "20191104.7";
|
||||
public const string YarnVersion = "1.17.3";
|
||||
public const string YarnMinorVersion = "1.17";
|
||||
public const string YarnMajorVersion = "1";
|
||||
|
|
|
@ -4,16 +4,16 @@ namespace Microsoft.Oryx.Common
|
|||
{
|
||||
public static class PhpVersions
|
||||
{
|
||||
public const string PhpBuildBaseTag = "20191025.2";
|
||||
public const string PhpRuntimeBaseTag = "20191025.2";
|
||||
public const string PhpBuildBaseTag = "20191104.7";
|
||||
public const string PhpRuntimeBaseTag = "20191104.7";
|
||||
public const string ComposerVersion = "1.9.0";
|
||||
public const string ComposerSha384 = "a5c698ffe4b8e849a443b120cd5ba38043260d5c4023dbf93e1558871f1f07f58274fc6f4c93bcfd858c6bd0775cd8d1";
|
||||
public const string Php73Version = "7.3.10";
|
||||
public const string Php73Version = "7.3.11";
|
||||
public const string Php73Keys = "CBAF69F173A0FEA4B537F470D66C9593118BCCB6 F38252826ACD957EF380D39F2F7956BC5DA04B5D";
|
||||
public const string Php73TarSha256 = "42f00a15419e05771734b7159c8d39d639b8a5a6770413adfa2615f6f923d906";
|
||||
public const string Php72Version = "7.2.23";
|
||||
public const string Php73TarSha256 = "657cf6464bac28e9490c59c07a2cf7bb76c200f09cfadf6e44ea64e95fa01021";
|
||||
public const string Php72Version = "7.2.24";
|
||||
public const string Php72Keys = "1729F83938DA44E27BA0F4D3DBDB397470D12172 B1B44D8F021E4E2D6021E995DC9FF8D3EE5AF27F";
|
||||
public const string Php72TarSha256 = "74e045ec8ff26290db6a3688826dcdf43b87bc509e508e9cb76dab742804ca14";
|
||||
public const string Php72TarSha256 = "a6a6cc03388060aa5f8f9e45799b72bce1c7ed7b9d7b3f1187787202aad91d25";
|
||||
public const string Php70Version = "7.0.33";
|
||||
public const string Php70Keys = "1A4E8B7277C42E53DBA9C7B9BCAA30EA9C0D5763 6E4F6AB321FDC07F2C332E3AC2BF0BC433CFC8B3";
|
||||
public const string Php70TarSha256 = "ab8c5be6e32b1f8d032909dedaaaa4bbb1a209e519abb01a52ce3914f9a13d96";
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace Microsoft.Oryx.Common
|
|||
{
|
||||
public static class PythonVersions
|
||||
{
|
||||
public const string PythonBaseTag = "20191025.2";
|
||||
public const string PythonBaseTag = "20191104.7";
|
||||
public const string PipVersion = "19.3.1";
|
||||
public const string Python27Version = "2.7.17";
|
||||
public const string Python36Version = "3.6.9";
|
||||
|
|
Загрузка…
Ссылка в новой задаче