From c5b206ddab1a7e67d43ffc99a36c28884bd4fe7a Mon Sep 17 00:00:00 2001 From: J0WI Date: Fri, 27 Mar 2020 23:59:51 +0100 Subject: [PATCH] Remove unused dependencies --- Dockerfile | 105 ++++++++++++++++++++++++++++++++--------------------- README.md | 6 +-- 2 files changed, 65 insertions(+), 46 deletions(-) diff --git a/Dockerfile b/Dockerfile index 12bd41d..4ca8d24 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,33 +1,67 @@ FROM php:7.3-apache LABEL maintainer="Andy Miller (@rhukster)" +# runtime dependencies +RUN set -ex; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + busybox \ + ; \ + rm -rf /var/lib/apt/lists/*; \ + \ + mkdir -p /var/spool/cron/crontabs; \ + echo '* * * * * php -f /var/www/html/bin/grav scheduler 1>> /dev/null 2>&1' > /var/spool/cron/crontabs/www-data + # Enable Apache Rewrite + Expires Module RUN a2enmod rewrite expires && \ sed -i 's/ServerTokens OS/ServerTokens ProductOnly/g' \ /etc/apache2/conf-available/security.conf -# Install dependencies -RUN apt-get update && apt-get install -y --no-install-recommends \ - unzip \ - libfreetype6-dev \ - libjpeg62-turbo-dev \ - libpng-dev \ - libyaml-dev \ - libzip4 \ - libzip-dev \ - zlib1g-dev \ - libicu-dev \ - g++ \ - git \ - cron \ - vim \ - && docker-php-ext-install opcache \ - && docker-php-ext-configure intl \ - && docker-php-ext-install intl \ - && docker-php-ext-configure gd --with-freetype --with-jpeg \ - && docker-php-ext-install -j$(nproc) gd \ - && docker-php-ext-install zip \ - && rm -rf /var/lib/apt/lists/* +RUN set -ex; \ + \ + savedAptMark="$(apt-mark showmanual)"; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + libfreetype6-dev \ + libicu-dev \ + libjpeg-dev \ + libpng-dev \ + libyaml-dev \ + libzip-dev \ + ; \ + \ + docker-php-ext-configure gd --with-freetype --with-jpeg; \ + docker-php-ext-install -j "$(nproc)" \ + gd \ + intl \ + opcache \ + zip \ + ; \ + \ +# pecl will claim success even if one install fails, so we need to perform each install separately + pecl install APCu-5.1.18; \ + pecl install yaml-2.0.4; \ + \ + docker-php-ext-enable \ + apcu \ + yaml \ + ; \ + \ +# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies + apt-mark auto '.*' > /dev/null; \ + apt-mark manual $savedAptMark; \ + ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \ + | awk '/=>/ { print $3 }' \ + | sort -u \ + | xargs -r dpkg-query -S \ + | cut -d: -f1 \ + | sort -u \ + | xargs -rt apt-mark manual; \ + \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ + rm -rf /var/lib/apt/lists/* # set recommended PHP.ini settings # see https://secure.php.net/manual/en/opcache.installation.php @@ -43,29 +77,16 @@ RUN { \ echo 'expose_php=off'; \ } > /usr/local/etc/php/conf.d/php-recommended.ini -RUN pecl install apcu \ - && pecl install yaml-2.0.4 \ - && docker-php-ext-enable apcu yaml - -# Set user to www-data -RUN chown www-data:www-data /var/www -USER www-data - # Define Grav specific version of Grav or use latest stable ENV GRAV_VERSION latest # Install grav -WORKDIR /var/www -RUN curl -o grav-admin.zip -SL https://getgrav.org/download/core/grav-admin/${GRAV_VERSION} && \ - unzip grav-admin.zip && \ - mv -T /var/www/grav-admin /var/www/html && \ - rm grav-admin.zip - -# Create cron job for Grav maintenance scripts -RUN (crontab -l; echo "* * * * * cd /var/www/html;/usr/local/bin/php bin/grav scheduler 1>> /dev/null 2>&1") | crontab - - -# Return to root user -USER root +RUN set -ex; \ + curl -o grav-admin.zip -fsSL https://getgrav.org/download/core/grav-admin/${GRAV_VERSION}; \ + busybox unzip -qd /var/www grav-admin.zip; \ + rm -r /var/www/html; \ + mv -T /var/www/grav-admin /var/www/html; \ + chown www-data:www-data -R /var/www/html # Copy init scripts # COPY docker-entrypoint.sh /entrypoint.sh @@ -75,4 +96,4 @@ VOLUME ["/var/www/html"] # ENTRYPOINT ["/entrypoint.sh"] # CMD ["apache2-foreground"] -CMD ["sh", "-c", "cron && apache2-foreground"] +CMD ["sh", "-c", "busybox crond && apache2-foreground"] diff --git a/README.md b/README.md index a5ab7a6..10c77f0 100644 --- a/README.md +++ b/README.md @@ -2,15 +2,13 @@ This currently is pretty minimal and uses: -* apache-2.4.38 +* Apache httpd 2.4 +* BusyBox * GD library -* Unzip library * php7.3 * php7.3-opcache * php7.3-acpu * php7.3-yaml -* cron -* vim editor ## Persisting data