-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
65 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters