From 61d7b18922006d582ae68ca0cdf5e202e5bcf08d Mon Sep 17 00:00:00 2001 From: "Shao Yu-Lung (Allen)" Date: Sat, 23 Feb 2019 16:46:46 +0800 Subject: [PATCH] Optimize php-fpm and workspace Dockerfile. (#2015) --- php-fpm/Dockerfile | 52 ++++++++++++++++---------------- workspace/Dockerfile | 71 +++++++++++++++++++++----------------------- 2 files changed, 61 insertions(+), 62 deletions(-) diff --git a/php-fpm/Dockerfile b/php-fpm/Dockerfile index 78a819a..0d4f7cd 100644 --- a/php-fpm/Dockerfile +++ b/php-fpm/Dockerfile @@ -24,27 +24,27 @@ ARG LARADOCK_PHP_VERSION ENV DEBIAN_FRONTEND noninteractive # always run apt update when start and after add new source list, then clean up at end. -RUN set -xe && apt-get update -yqq && \ - apt-get install -y apt-utils && \ - pecl channel-update pecl.php.net - -# -#-------------------------------------------------------------------------- -# 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 -# 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 - -RUN apt-get install libzip-dev zip unzip -y && \ - docker-php-ext-configure zip --with-libzip && \ - # Install the zip extension - docker-php-ext-install zip +RUN set -xe; \ + apt-get update -yqq && \ + pecl channel-update pecl.php.net && \ + apt-get install -yqq \ + apt-utils \ + # + #-------------------------------------------------------------------------- + # 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 + # 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 + libzip-dev zip unzip && \ + docker-php-ext-configure zip --with-libzip && \ + # Install the zip extension + docker-php-ext-install zip && \ + php -m | grep -q 'zip' # #-------------------------------------------------------------------------- @@ -340,7 +340,8 @@ USER root 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 apt-get -y install sudo wget && \ # Install the php aerospike extension @@ -455,7 +456,8 @@ RUN if [ ${INSTALL_LDAP} = true ]; then \ 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 \ apt-get -y install freetds-dev libsybdb5 \ && 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 'sqlsrv' \ ;fi \ -;fi + ;fi ########################################################################### # Image optimizers: @@ -628,7 +630,7 @@ RUN if [ ${INSTALL_MYSQL_CLIENT} = true ]; then \ # 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}." # #-------------------------------------------------------------------------- diff --git a/workspace/Dockerfile b/workspace/Dockerfile index 11676ff..9c16f17 100644 --- a/workspace/Dockerfile +++ b/workspace/Dockerfile @@ -37,28 +37,31 @@ ARG PGID=1000 ENV PGID ${PGID} # 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 && \ groupadd -g ${PGID} laradock && \ useradd -u ${PUID} -g laradock -m laradock -G docker_env && \ - usermod -p "*" laradock -s /bin/bash - -# -#-------------------------------------------------------------------------- -# 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 -# 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 - -RUN apt-get install -y libzip-dev zip unzip \ - # Install the zip extension - php${LARADOCK_PHP_VERSION}-zip + usermod -p "*" laradock -s /bin/bash && \ + apt-get install -yqq \ + apt-utils \ + # + #-------------------------------------------------------------------------- + # 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 + # 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 + libzip-dev zip unzip \ + # Install the zip extension + php${LARADOCK_PHP_VERSION}-zip \ + # nasm + nasm && \ + php -m | grep -q 'zip' # #-------------------------------------------------------------------------- @@ -96,14 +99,14 @@ RUN sed -i 's/\r//' /root/aliases.sh && \ echo "" >> ~/.bashrc && \ echo "# Load Custom Aliases" >> ~/.bashrc && \ echo "source ~/aliases.sh" >> ~/.bashrc && \ - echo "" >> ~/.bashrc + echo "" >> ~/.bashrc USER laradock RUN echo "" >> ~/.bashrc && \ echo "# Load Custom Aliases" >> ~/.bashrc && \ echo "source ~/aliases.sh" >> ~/.bashrc && \ - echo "" >> ~/.bashrc + echo "" >> ~/.bashrc ########################################################################### # Composer: @@ -583,7 +586,8 @@ USER root 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 apt-get -y install sudo wget && \ # 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 '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 \ -;fi + ;fi ########################################################################### # PHP V8JS: @@ -624,7 +628,8 @@ USER root 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 \ && apt-get update -yqq \ && apt-get install -y libv8-5.4 && \ @@ -635,7 +640,7 @@ RUN set -xe && if [ ${INSTALL_V8JS} = true ]; then \ fi \ && echo "extension=v8js.so" >> /etc/php/${LARADOCK_PHP_VERSION}/cli/php.ini \ && php -m | grep -q 'v8js' \ -;fi + ;fi ########################################################################### # Laravel Envoy: @@ -733,7 +738,8 @@ RUN if [ ${INSTALL_LINUXBREW} = true ]; then \ 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 \ apt-get -y install php5.6-sybase freetds-bin freetds-common libsybdb5 \ && 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 'pdo_sqlsrv' \ ;fi \ -;fi + ;fi ########################################################################### # Minio: @@ -871,15 +877,6 @@ RUN if [ ${INSTALL_PG_CLIENT} = true ]; then \ && apt-get -y install postgresql-client-10 \ ;fi -########################################################################### -# nasm -########################################################################### - -USER root - -RUN apt-get update -yqq \ - && apt-get -yqq install nasm - ########################################################################### # Dusk Dependencies: ########################################################################### @@ -942,7 +939,7 @@ RUN if [ ${INSTALL_MYSQL_CLIENT} = true ]; then \ # 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}." # #--------------------------------------------------------------------------