From 59e9a5591149d99eea53869414a17ee4574816dd Mon Sep 17 00:00:00 2001 From: madmath03 Date: Thu, 19 Apr 2018 11:09:40 +0200 Subject: [PATCH 1/3] Reduce number of layers --- cli/Dockerfile | 46 +++++++++---------- php5-fpm/Dockerfile | 64 ++++++++++++-------------- php7-fpm/Dockerfile | 106 +++++++++++++++++++------------------------- 3 files changed, 96 insertions(+), 120 deletions(-) diff --git a/cli/Dockerfile b/cli/Dockerfile index 0304639..d012f96 100644 --- a/cli/Dockerfile +++ b/cli/Dockerfile @@ -9,39 +9,37 @@ RUN apt-get update && \ less \ mysql-client \ libjpeg-dev \ - libpng-dev - -RUN docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr && \ - docker-php-ext-install gd mysqli opcache - -# set recommended PHP.ini settings -# see https://secure.php.net/manual/en/opcache.installation.php -RUN { \ + libpng-dev && \ + docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr && \ + docker-php-ext-install gd mysqli opcache && \ + # set recommended PHP.ini settings + # see https://secure.php.net/manual/en/opcache.installation.php + { \ echo 'opcache.memory_consumption=128'; \ echo 'opcache.interned_strings_buffer=8'; \ echo 'opcache.max_accelerated_files=4000'; \ echo 'opcache.revalidate_freq=2'; \ echo 'opcache.fast_shutdown=1'; \ echo 'opcache.enable_cli=1'; \ -} > /usr/local/etc/php/conf.d/opcache-recommended.ini - -# Install needed php extensions: ldap -# -RUN apt-get install libldap2-dev -y && \ + } > /usr/local/etc/php/conf.d/opcache-recommended.ini && \ + # Install needed php extensions: ldap + # + apt-get install libldap2-dev -y && \ docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ && \ - docker-php-ext-install ldap - -RUN mkdir -p /var/www/html && \ - chown -R www-data:www-data /var/www/html - -RUN curl -L https://github.com/wp-cli/wp-cli/releases/download/v${WORDPRESS_CLI_VERSION}/wp-cli-${WORDPRESS_CLI_VERSION}.phar \ + docker-php-ext-install ldap && \ + # Prepare folders + # + mkdir -p /var/www/html && \ + chown -R www-data:www-data /var/www/html && \ + # Install WP-CLI + # + curl -L https://github.com/wp-cli/wp-cli/releases/download/v${WORDPRESS_CLI_VERSION}/wp-cli-${WORDPRESS_CLI_VERSION}.phar \ -o /usr/local/bin/wp-cli.phar && \ chmod +x /usr/local/bin/wp-cli.phar && \ ln -s /usr/local/bin/wp-cli.phar /bin/wp && \ - wp --allow-root --version - -# Cleanup -RUN rm -rf /var/lib/apt/lists/* + wp --allow-root --version && \ + # Cleanup + rm -rf /var/lib/apt/lists/* COPY docker-entrypoint.sh /docker-entrypoint.sh RUN chmod +x /docker-entrypoint.sh @@ -53,4 +51,4 @@ VOLUME /var/www/html USER www-data ENTRYPOINT [ "/docker-entrypoint.sh" ] -CMD ["wp", "shell"] \ No newline at end of file +CMD ["wp", "shell"] diff --git a/php5-fpm/Dockerfile b/php5-fpm/Dockerfile index 21488f9..22d5394 100644 --- a/php5-fpm/Dockerfile +++ b/php5-fpm/Dockerfile @@ -2,58 +2,50 @@ FROM wordpress:4.9.4-php5.6-fpm LABEL maintainer='Florian JUDITH ' -RUN apt-get update -RUN apt-get install --no-install-recommends -y tidy csstidy nano netcat - -RUN mkdir -p /usr/src/php/ext - -# Install needed php extensions: memcached -# -RUN apt-get install --no-install-recommends -y libmemcached-dev && \ +RUN apt-get update && \ + apt-get install --no-install-recommends -y tidy csstidy nano netcat && \ + mkdir -p /usr/src/php/ext && \ + # Install needed php extensions: memcached + # + apt-get install --no-install-recommends -y libmemcached-dev && \ curl -o memcached.tgz -SL http://pecl.php.net/get/memcached-2.2.0.tgz && \ tar -xf memcached.tgz -C /usr/src/php/ext/ && \ echo extension=memcached.so >> /usr/local/etc/php/conf.d/memcached.ini && \ rm memcached.tgz && \ - mv /usr/src/php/ext/memcached-2.2.0 /usr/src/php/ext/memcached - -# set recommended PHP.ini settings -# see https://secure.php.net/manual/en/opcache.installation.php -RUN { \ + mv /usr/src/php/ext/memcached-2.2.0 /usr/src/php/ext/memcached && \ + # set recommended PHP.ini settings + # see https://secure.php.net/manual/en/opcache.installation.php + { \ echo 'opcache.memory_consumption=128'; \ echo 'opcache.interned_strings_buffer=8'; \ echo 'opcache.max_accelerated_files=4000'; \ echo 'opcache.revalidate_freq=2'; \ echo 'opcache.fast_shutdown=1'; \ echo 'opcache.enable_cli=1'; \ - } > /usr/local/etc/php/conf.d/opcache-recommended.ini - -# Install needed php extensions: memcache -# -RUN curl -o memcache.tgz -SL http://pecl.php.net/get/memcache-3.0.8.tgz && \ + } > /usr/local/etc/php/conf.d/opcache-recommended.ini && \ + # Install needed php extensions: memcache + # + curl -o memcache.tgz -SL http://pecl.php.net/get/memcache-3.0.8.tgz && \ tar -xf memcache.tgz -C /usr/src/php/ext/ && \ rm memcache.tgz && \ - mv /usr/src/php/ext/memcache-3.0.8 /usr/src/php/ext/memcache - -RUN apt-get install -y --no-install-recommends libz-dev && \ + mv /usr/src/php/ext/memcache-3.0.8 /usr/src/php/ext/memcache && \ + apt-get install -y --no-install-recommends libz-dev && \ curl -o zip.tgz -SL http://pecl.php.net/get/zip-1.15.1.tgz && \ tar -xf zip.tgz -C /usr/src/php/ext/ && \ rm zip.tgz && \ - mv /usr/src/php/ext/zip-1.15.1 /usr/src/php/ext/zip - -RUN docker-php-ext-install memcached -RUN docker-php-ext-install memcache -RUN docker-php-ext-install zip - -# Install needed php extensions: ldap -# -RUN apt-get install --no-install-recommends -y libldap2-dev && \ - docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ && \ - docker-php-ext-install ldap - -# Cleanup -RUN rm -rf /var/lib/apt/lists/* + mv /usr/src/php/ext/zip-1.15.1 /usr/src/php/ext/zip && \ + docker-php-ext-install memcached && \ + docker-php-ext-install memcache && \ + docker-php-ext-install zip && \ + # Install needed php extensions: ldap + # + apt-get install --no-install-recommends -y libldap2-dev && \ + docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ && \ + docker-php-ext-install ldap && \ + # Cleanup + rm -rf /var/lib/apt/lists/* # ENTRYPOINT resets CMD ENTRYPOINT ["docker-entrypoint.sh"] -CMD ["php-fpm"] \ No newline at end of file +CMD ["php-fpm"] diff --git a/php7-fpm/Dockerfile b/php7-fpm/Dockerfile index 3a8ec8e..f5e2ad7 100644 --- a/php7-fpm/Dockerfile +++ b/php7-fpm/Dockerfile @@ -2,88 +2,74 @@ FROM wordpress:4.9.4-php7.1-fpm LABEL maintainer='Florian JUDITH ' -RUN apt-get update -RUN apt-get install --no-install-recommends -y tidy csstidy nano netcat - -RUN mkdir -p /usr/src/php/ext - -# Install needed php extensions: memcached -# -RUN apt-get install -y libpq-dev libmemcached-dev && \ +RUN apt-get update && \ + apt-get install --no-install-recommends -y tidy csstidy nano netcat && \ + mkdir -p /usr/src/php/ext && \ + # Install needed php extensions: memcached + # + apt-get install -y libpq-dev libmemcached-dev && \ curl -o memcached.tgz -SL http://pecl.php.net/get/memcached-3.0.3.tgz && \ tar -xf memcached.tgz -C /usr/src/php/ext/ && \ echo extension=memcached.so >> /usr/local/etc/php/conf.d/memcached.ini && \ rm memcached.tgz && \ - mv /usr/src/php/ext/memcached-3.0.3 /usr/src/php/ext/memcached - -# set recommended PHP.ini settings -# see https://secure.php.net/manual/en/opcache.installation.php -RUN { \ + mv /usr/src/php/ext/memcached-3.0.3 /usr/src/php/ext/memcached && \ + # set recommended PHP.ini settings + # see https://secure.php.net/manual/en/opcache.installation.php + { \ echo 'opcache.memory_consumption=128'; \ echo 'opcache.interned_strings_buffer=8'; \ echo 'opcache.max_accelerated_files=4000'; \ echo 'opcache.revalidate_freq=2'; \ echo 'opcache.fast_shutdown=1'; \ echo 'opcache.enable_cli=1'; \ - } > /usr/local/etc/php/conf.d/opcache-recommended.ini - - -# Install needed php extensions: memcache -# -RUN apt-get install --no-install-recommends -y unzip libssl-dev libpcre3 libpcre3-dev && \ + } > /usr/local/etc/php/conf.d/opcache-recommended.ini && \ + # Install needed php extensions: memcache + # + apt-get install --no-install-recommends -y unzip libssl-dev libpcre3 libpcre3-dev && \ cd /usr/src/php/ext/ && \ curl -sSL -o php7.zip https://github.com/websupport-sk/pecl-memcache/archive/NON_BLOCKING_IO_php7.zip && \ - unzip php7.zip && \ - mv pecl-memcache-NON_BLOCKING_IO_php7 memcache && \ + unzip php7.zip && \ + mv pecl-memcache-NON_BLOCKING_IO_php7 memcache && \ docker-php-ext-configure memcache --with-php-config=/usr/local/bin/php-config && \ docker-php-ext-install memcache && \ echo "extension=memcache.so" > /usr/local/etc/php/conf.d/ext-memcache.ini && \ - rm -rf /tmp/pecl-memcache-php7 php7.zip - - -# Install needed php extensions: zip -# -RUN apt-get install -y libz-dev && \ + rm -rf /tmp/pecl-memcache-php7 php7.zip && \ + # Install needed php extensions: zip + # + apt-get install -y libz-dev && \ curl -o zip.tgz -SL http://pecl.php.net/get/zip-1.15.1.tgz && \ tar -xf zip.tgz -C /usr/src/php/ext/ && \ rm zip.tgz && \ - mv /usr/src/php/ext/zip-1.15.1 /usr/src/php/ext/zip - -RUN docker-php-ext-install memcached -RUN docker-php-ext-install memcache -RUN docker-php-ext-install zip - - -# Install needed php extensions: ldap -# -RUN apt-get install libldap2-dev -y && \ + mv /usr/src/php/ext/zip-1.15.1 /usr/src/php/ext/zip && \ + docker-php-ext-install memcached && \ + docker-php-ext-install memcache && \ + docker-php-ext-install zip && \ + # Install needed php extensions: ldap + # + apt-get install libldap2-dev -y && \ docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ && \ - docker-php-ext-install ldap - -# Install needed wordpress extensions: WP-FFPC -# -RUN cd /usr/src/wordpress/wp-content/plugins && \ + docker-php-ext-install ldap && \ + # Install needed wordpress extensions: WP-FFPC + # + cd /usr/src/wordpress/wp-content/plugins && \ curl -o wp-ffpc.zip -L https://downloads.wordpress.org/plugin/wp-ffpc.zip && \ - unzip -o wp-ffpc.zip && \ - chown -R www-data:www-data wp-ffpc && \ - rm -f wp-ffpc.zip - -# Enable Wordpress Caching -RUN cd /usr/src/wordpress && ls -l && \ - sed -ri -e "s#(<\?php)#\\1\ndefine('WP_CACHE', 'true');#g" wp-config-sample.php - -# Install needed wordpress extensions: Simple-Ldap-Login -# -RUN cd /usr/src/wordpress/wp-content/plugins && \ + unzip -o wp-ffpc.zip && \ + chown -R www-data:www-data wp-ffpc && \ + rm -f wp-ffpc.zip && \ + # Enable Wordpress Caching + cd /usr/src/wordpress && ls -l && \ + sed -ri -e "s#(<\?php)#\\1\ndefine('WP_CACHE', 'true');#g" wp-config-sample.php && \ + # Install needed wordpress extensions: Simple-Ldap-Login + # + cd /usr/src/wordpress/wp-content/plugins && \ curl -o simple-ldap-login.zip -L https://downloads.wordpress.org/plugin/simple-ldap-login.1.6.0.zip && \ - unzip -o simple-ldap-login.zip && \ - chown -R www-data:www-data simple-ldap-login && \ - rm -f simple-ldap-login.zip - -# Cleanup -RUN rm -rf /var/lib/apt/lists/* + unzip -o simple-ldap-login.zip && \ + chown -R www-data:www-data simple-ldap-login && \ + rm -f simple-ldap-login.zip && \ + # Cleanup + rm -rf /var/lib/apt/lists/* # ENTRYPOINT resets CMD ENTRYPOINT ["docker-entrypoint.sh"] -CMD ["php-fpm"] \ No newline at end of file +CMD ["php-fpm"] From 983e6f0bbf3ce6df4c0115c3e0ec59359dc91e2c Mon Sep 17 00:00:00 2001 From: madmath03 Date: Thu, 19 Apr 2018 11:18:58 +0200 Subject: [PATCH 2/3] Minor typo in doc --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bab2d14..70e27e4 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ Set the following minimal configuration options: ## Updating -Because the `docker-compose` levegare persistent volume in the Wordpress root directory, its required to open a session in the `cli` container in order to run the command `wp core update`. +Because the `docker-compose` leverage persistent volume in the Wordpress root directory, its required to open a session in the `cli` container in order to run the command `wp core update`. ### Interactive From c13f14e27816e3a480d87226b27aaa92ae324eca Mon Sep 17 00:00:00 2001 From: madmath03 Date: Thu, 19 Apr 2018 19:12:06 +0200 Subject: [PATCH 3/3] Remove duplicate memcache install --- .travis.yml | 2 +- php7-fpm/Dockerfile | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 75acc50..8f0d297 100644 --- a/.travis.yml +++ b/.travis.yml @@ -120,4 +120,4 @@ after_success: - docker tag ${REPO}:${COMMIT}-cli ${REPO}:${CLI} - docker tag ${REPO}:${COMMIT}-cli ${REPO}:travis-${TRAVIS_BUILD_NUMBER}-cli # push to public registry -- docker push ${REPO} \ No newline at end of file + - docker push ${REPO} diff --git a/php7-fpm/Dockerfile b/php7-fpm/Dockerfile index f5e2ad7..e5c5358 100644 --- a/php7-fpm/Dockerfile +++ b/php7-fpm/Dockerfile @@ -32,6 +32,7 @@ RUN apt-get update && \ mv pecl-memcache-NON_BLOCKING_IO_php7 memcache && \ docker-php-ext-configure memcache --with-php-config=/usr/local/bin/php-config && \ docker-php-ext-install memcache && \ + docker-php-ext-install memcached && \ echo "extension=memcache.so" > /usr/local/etc/php/conf.d/ext-memcache.ini && \ rm -rf /tmp/pecl-memcache-php7 php7.zip && \ # Install needed php extensions: zip @@ -41,8 +42,6 @@ RUN apt-get update && \ tar -xf zip.tgz -C /usr/src/php/ext/ && \ rm zip.tgz && \ mv /usr/src/php/ext/zip-1.15.1 /usr/src/php/ext/zip && \ - docker-php-ext-install memcached && \ - docker-php-ext-install memcache && \ docker-php-ext-install zip && \ # Install needed php extensions: ldap #