Skip to content

Commit

Permalink
Remove unused dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
J0WI committed Aug 6, 2020
1 parent b8014e8 commit c5b206d
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 46 deletions.
105 changes: 63 additions & 42 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,33 +1,67 @@
FROM php:7.3-apache
LABEL maintainer="Andy Miller <[email protected]> (@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
Expand All @@ -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
Expand All @@ -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"]
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit c5b206d

Please sign in to comment.