Optimize php-fpm and workspace Dockerfile. (#2015)

This commit is contained in:
Shao Yu-Lung (Allen) 2019-02-23 16:46:46 +08:00 committed by GitHub
parent cde20c3ced
commit 61d7b18922
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 61 additions and 62 deletions

View File

@ -24,27 +24,27 @@ ARG LARADOCK_PHP_VERSION
ENV DEBIAN_FRONTEND noninteractive ENV DEBIAN_FRONTEND noninteractive
# always run apt update when start and after add new source list, then clean up at end. # always run apt update when start and after add new source list, then clean up at end.
RUN set -xe && apt-get update -yqq && \ RUN set -xe; \
apt-get install -y apt-utils && \ apt-get update -yqq && \
pecl channel-update pecl.php.net pecl channel-update pecl.php.net && \
apt-get install -yqq \
# apt-utils \
#-------------------------------------------------------------------------- #
# Mandatory Software's Installation #--------------------------------------------------------------------------
#-------------------------------------------------------------------------- # Mandatory Software's Installation
# #--------------------------------------------------------------------------
# Mandatory Software's such as ("mcrypt", "pdo_mysql", "libssl-dev", ....) #
# are installed on the base image 'laradock/php-fpm' image. If you want # Mandatory Software's such as ("mcrypt", "pdo_mysql", "libssl-dev", ....)
# to add more Software's or remove existing one, you need to edit the # are installed on the base image 'laradock/php-fpm' image. If you want
# base image (https://github.com/Laradock/php-fpm). # to add more Software's or remove existing one, you need to edit the
# # base image (https://github.com/Laradock/php-fpm).
# next lines are here becase there is no auto build on dockerhub see https://github.com/laradock/laradock/pull/1903#issuecomment-463142846 #
USER root # next lines are here becase there is no auto build on dockerhub see https://github.com/laradock/laradock/pull/1903#issuecomment-463142846
libzip-dev zip unzip && \
RUN apt-get install libzip-dev zip unzip -y && \
docker-php-ext-configure zip --with-libzip && \ docker-php-ext-configure zip --with-libzip && \
# Install the zip extension # Install the zip extension
docker-php-ext-install zip docker-php-ext-install zip && \
php -m | grep -q 'zip'
# #
#-------------------------------------------------------------------------- #--------------------------------------------------------------------------
@ -340,7 +340,8 @@ USER root
ARG INSTALL_AEROSPIKE=false ARG INSTALL_AEROSPIKE=false
RUN set -xe && if [ ${INSTALL_AEROSPIKE} = true ]; then \ RUN set -xe; \
if [ ${INSTALL_AEROSPIKE} = true ]; then \
# Fix dependencies for PHPUnit within aerospike extension # Fix dependencies for PHPUnit within aerospike extension
apt-get -y install sudo wget && \ apt-get -y install sudo wget && \
# Install the php aerospike extension # Install the php aerospike extension
@ -455,7 +456,8 @@ RUN if [ ${INSTALL_LDAP} = true ]; then \
ARG INSTALL_MSSQL=false ARG INSTALL_MSSQL=false
RUN set -eux; if [ ${INSTALL_MSSQL} = true ]; then \ RUN set -eux; \
if [ ${INSTALL_MSSQL} = true ]; then \
if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \ if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \
apt-get -y install freetds-dev libsybdb5 \ apt-get -y install freetds-dev libsybdb5 \
&& ln -s /usr/lib/x86_64-linux-gnu/libsybdb.so /usr/lib/libsybdb.so \ && ln -s /usr/lib/x86_64-linux-gnu/libsybdb.so /usr/lib/libsybdb.so \
@ -487,7 +489,7 @@ RUN set -eux; if [ ${INSTALL_MSSQL} = true ]; then \
&& php -m | grep -q 'pdo_sqlsrv' \ && php -m | grep -q 'pdo_sqlsrv' \
&& php -m | grep -q 'sqlsrv' \ && php -m | grep -q 'sqlsrv' \
;fi \ ;fi \
;fi ;fi
########################################################################### ###########################################################################
# Image optimizers: # Image optimizers:
@ -628,7 +630,7 @@ RUN if [ ${INSTALL_MYSQL_CLIENT} = true ]; then \
# Check PHP version: # Check PHP version:
########################################################################### ###########################################################################
RUN php -v | head -n 1 | grep -q "PHP ${LARADOCK_PHP_VERSION}." RUN set -xe; php -v | head -n 1 | grep -q "PHP ${LARADOCK_PHP_VERSION}."
# #
#-------------------------------------------------------------------------- #--------------------------------------------------------------------------

View File

@ -37,28 +37,31 @@ ARG PGID=1000
ENV PGID ${PGID} ENV PGID ${PGID}
# always run apt update when start and after add new source list, then clean up at end. # always run apt update when start and after add new source list, then clean up at end.
RUN set -xe && apt-get update -yqq && \ RUN set -xe; \
apt-get update -yqq && \
pecl channel-update pecl.php.net && \ pecl channel-update pecl.php.net && \
groupadd -g ${PGID} laradock && \ groupadd -g ${PGID} laradock && \
useradd -u ${PUID} -g laradock -m laradock -G docker_env && \ useradd -u ${PUID} -g laradock -m laradock -G docker_env && \
usermod -p "*" laradock -s /bin/bash usermod -p "*" laradock -s /bin/bash && \
apt-get install -yqq \
# apt-utils \
#-------------------------------------------------------------------------- #
# Mandatory Software's Installation #--------------------------------------------------------------------------
#-------------------------------------------------------------------------- # Mandatory Software's Installation
# #--------------------------------------------------------------------------
# Mandatory Software's such as ("php-cli", "git", "vim", ....) are #
# installed on the base image 'laradock/workspace' image. If you want # Mandatory Software's such as ("php-cli", "git", "vim", ....) are
# to add more Software's or remove existing one, you need to edit the # installed on the base image 'laradock/workspace' image. If you want
# base image (https://github.com/Laradock/workspace). # to add more Software's or remove existing one, you need to edit the
# # base image (https://github.com/Laradock/workspace).
# next lines are here becase there is no auto build on dockerhub see https://github.com/laradock/laradock/pull/1903#issuecomment-463142846 #
USER root # next lines are here becase there is no auto build on dockerhub see https://github.com/laradock/laradock/pull/1903#issuecomment-463142846
libzip-dev zip unzip \
RUN apt-get install -y libzip-dev zip unzip \
# Install the zip extension # Install the zip extension
php${LARADOCK_PHP_VERSION}-zip php${LARADOCK_PHP_VERSION}-zip \
# nasm
nasm && \
php -m | grep -q 'zip'
# #
#-------------------------------------------------------------------------- #--------------------------------------------------------------------------
@ -583,7 +586,8 @@ USER root
ARG INSTALL_AEROSPIKE=false ARG INSTALL_AEROSPIKE=false
RUN set -xe && if [ ${INSTALL_AEROSPIKE} = true ]; then \ RUN set -xe; \
if [ ${INSTALL_AEROSPIKE} = true ]; then \
# Fix dependencies for PHPUnit within aerospike extension # Fix dependencies for PHPUnit within aerospike extension
apt-get -y install sudo wget && \ apt-get -y install sudo wget && \
# Install the php aerospike extension # Install the php aerospike extension
@ -614,7 +618,7 @@ RUN set -xe && if [ ${INSTALL_AEROSPIKE} = true ]; then \
&& echo 'extension=aerospike.so' >> /etc/php/${LARADOCK_PHP_VERSION}/cli/conf.d/aerospike.ini \ && echo 'extension=aerospike.so' >> /etc/php/${LARADOCK_PHP_VERSION}/cli/conf.d/aerospike.ini \
&& echo 'aerospike.udf.lua_system_path=/usr/local/aerospike/lua' >> /etc/php/${LARADOCK_PHP_VERSION}/cli/conf.d/aerospike.ini \ && echo 'aerospike.udf.lua_system_path=/usr/local/aerospike/lua' >> /etc/php/${LARADOCK_PHP_VERSION}/cli/conf.d/aerospike.ini \
&& echo 'aerospike.udf.lua_user_path=/usr/local/aerospike/usr-lua' >> /etc/php/${LARADOCK_PHP_VERSION}/cli/conf.d/aerospike.ini \ && echo 'aerospike.udf.lua_user_path=/usr/local/aerospike/usr-lua' >> /etc/php/${LARADOCK_PHP_VERSION}/cli/conf.d/aerospike.ini \
;fi ;fi
########################################################################### ###########################################################################
# PHP V8JS: # PHP V8JS:
@ -624,7 +628,8 @@ USER root
ARG INSTALL_V8JS=false ARG INSTALL_V8JS=false
RUN set -xe && if [ ${INSTALL_V8JS} = true ]; then \ RUN set -xe; \
if [ ${INSTALL_V8JS} = true ]; then \
add-apt-repository -y ppa:pinepain/libv8-archived \ add-apt-repository -y ppa:pinepain/libv8-archived \
&& apt-get update -yqq \ && apt-get update -yqq \
&& apt-get install -y libv8-5.4 && \ && apt-get install -y libv8-5.4 && \
@ -635,7 +640,7 @@ RUN set -xe && if [ ${INSTALL_V8JS} = true ]; then \
fi \ fi \
&& echo "extension=v8js.so" >> /etc/php/${LARADOCK_PHP_VERSION}/cli/php.ini \ && echo "extension=v8js.so" >> /etc/php/${LARADOCK_PHP_VERSION}/cli/php.ini \
&& php -m | grep -q 'v8js' \ && php -m | grep -q 'v8js' \
;fi ;fi
########################################################################### ###########################################################################
# Laravel Envoy: # Laravel Envoy:
@ -733,7 +738,8 @@ RUN if [ ${INSTALL_LINUXBREW} = true ]; then \
ARG INSTALL_MSSQL=false ARG INSTALL_MSSQL=false
RUN set -eux; if [ ${INSTALL_MSSQL} = true ]; then \ RUN set -eux; \
if [ ${INSTALL_MSSQL} = true ]; then \
if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \ if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \
apt-get -y install php5.6-sybase freetds-bin freetds-common libsybdb5 \ apt-get -y install php5.6-sybase freetds-bin freetds-common libsybdb5 \
&& php -m | grep -q 'mssql' \ && php -m | grep -q 'mssql' \
@ -761,7 +767,7 @@ RUN set -eux; if [ ${INSTALL_MSSQL} = true ]; then \
&& php -m | grep -q 'sqlsrv' \ && php -m | grep -q 'sqlsrv' \
&& php -m | grep -q 'pdo_sqlsrv' \ && php -m | grep -q 'pdo_sqlsrv' \
;fi \ ;fi \
;fi ;fi
########################################################################### ###########################################################################
# Minio: # Minio:
@ -871,15 +877,6 @@ RUN if [ ${INSTALL_PG_CLIENT} = true ]; then \
&& apt-get -y install postgresql-client-10 \ && apt-get -y install postgresql-client-10 \
;fi ;fi
###########################################################################
# nasm
###########################################################################
USER root
RUN apt-get update -yqq \
&& apt-get -yqq install nasm
########################################################################### ###########################################################################
# Dusk Dependencies: # Dusk Dependencies:
########################################################################### ###########################################################################
@ -942,7 +939,7 @@ RUN if [ ${INSTALL_MYSQL_CLIENT} = true ]; then \
# Check PHP version: # Check PHP version:
########################################################################### ###########################################################################
RUN php -v | head -n 1 | grep -q "PHP ${LARADOCK_PHP_VERSION}." RUN set -xe; php -v | head -n 1 | grep -q "PHP ${LARADOCK_PHP_VERSION}."
# #
#-------------------------------------------------------------------------- #--------------------------------------------------------------------------