Skip to content

Commit fc11694

Browse files
committed
Remove unused dependencies
1 parent 47c803c commit fc11694

File tree

2 files changed

+65
-46
lines changed

2 files changed

+65
-46
lines changed

Dockerfile

Lines changed: 63 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,65 @@
11
FROM php:7.3-apache
22
LABEL maintainer="Andy Miller <[email protected]> (@rhukster)"
33

4+
# runtime dependencies
5+
RUN set -ex; \
6+
\
7+
apt-get update; \
8+
apt-get install -y --no-install-recommends \
9+
busybox-static \
10+
; \
11+
rm -rf /var/lib/apt/lists/*; \
12+
\
13+
mkdir -p /var/spool/cron/crontabs; \
14+
echo '* * * * * php -f /var/www/html/bin/grav scheduler 1>> /dev/null 2>&1' > /var/spool/cron/crontabs/www-data
15+
416
# Enable Apache Rewrite + Expires Module
517
RUN a2enmod rewrite expires
618

7-
# Install dependencies
8-
RUN apt-get update && apt-get install -y --no-install-recommends \
9-
unzip \
10-
libfreetype6-dev \
11-
libjpeg62-turbo-dev \
12-
libpng-dev \
13-
libyaml-dev \
14-
libzip4 \
15-
libzip-dev \
16-
zlib1g-dev \
17-
libicu-dev \
18-
g++ \
19-
git \
20-
cron \
21-
vim \
22-
&& docker-php-ext-install opcache \
23-
&& docker-php-ext-configure intl \
24-
&& docker-php-ext-install intl \
25-
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
26-
&& docker-php-ext-install -j$(nproc) gd \
27-
&& docker-php-ext-install zip \
28-
&& rm -rf /var/lib/apt/lists/*
19+
RUN set -ex; \
20+
\
21+
savedAptMark="$(apt-mark showmanual)"; \
22+
\
23+
apt-get update; \
24+
apt-get install -y --no-install-recommends \
25+
libfreetype6-dev \
26+
libicu-dev \
27+
libjpeg-dev \
28+
libpng-dev \
29+
libyaml-dev \
30+
libzip-dev \
31+
; \
32+
\
33+
docker-php-ext-configure gd --with-freetype-dir=/usr --with-png-dir=/usr --with-jpeg-dir=/usr; \
34+
docker-php-ext-install -j "$(nproc)" \
35+
gd \
36+
intl \
37+
opcache \
38+
zip \
39+
; \
40+
\
41+
# pecl will claim success even if one install fails, so we need to perform each install separately
42+
pecl install APCu-5.1.18; \
43+
pecl install yaml-2.0.4; \
44+
\
45+
docker-php-ext-enable \
46+
apcu \
47+
yaml \
48+
; \
49+
\
50+
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
51+
apt-mark auto '.*' > /dev/null; \
52+
apt-mark manual $savedAptMark; \
53+
ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \
54+
| awk '/=>/ { print $3 }' \
55+
| sort -u \
56+
| xargs -r dpkg-query -S \
57+
| cut -d: -f1 \
58+
| sort -u \
59+
| xargs -rt apt-mark manual; \
60+
\
61+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
62+
rm -rf /var/lib/apt/lists/*
2963

3064
# set recommended PHP.ini settings
3165
# see https://secure.php.net/manual/en/opcache.installation.php
@@ -40,29 +74,16 @@ RUN { \
4074
echo 'post_max_size=128M'; \
4175
} > /usr/local/etc/php/conf.d/php-recommended.ini
4276

43-
RUN pecl install apcu \
44-
&& pecl install yaml-2.0.4 \
45-
&& docker-php-ext-enable apcu yaml
46-
47-
# Set user to www-data
48-
RUN chown www-data:www-data /var/www
49-
USER www-data
50-
5177
# Define Grav specific version of Grav or use latest stable
5278
ENV GRAV_VERSION latest
5379

5480
# Install grav
55-
WORKDIR /var/www
56-
RUN curl -o grav-admin.zip -SL https://getgrav.org/download/core/grav-admin/${GRAV_VERSION} && \
57-
unzip grav-admin.zip && \
58-
mv -T /var/www/grav-admin /var/www/html && \
59-
rm grav-admin.zip
60-
61-
# Create cron job for Grav maintenance scripts
62-
RUN (crontab -l; echo "* * * * * cd /var/www/html;/usr/local/bin/php bin/grav scheduler 1>> /dev/null 2>&1") | crontab -
63-
64-
# Return to root user
65-
USER root
81+
RUN set -ex; \
82+
curl -o grav-admin.zip -fsSL https://getgrav.org/download/core/grav-admin/${GRAV_VERSION}; \
83+
busybox unzip -qd /var/www grav-admin.zip; \
84+
rm -r /var/www/html; \
85+
mv -T /var/www/grav-admin /var/www/html; \
86+
chown www-data:www-data -R /var/www/html
6687

6788
# Copy init scripts
6889
# COPY docker-entrypoint.sh /entrypoint.sh
@@ -72,4 +93,4 @@ VOLUME ["/var/www/html"]
7293

7394
# ENTRYPOINT ["/entrypoint.sh"]
7495
# CMD ["apache2-foreground"]
75-
CMD ["sh", "-c", "cron && apache2-foreground"]
96+
CMD ["sh", "-c", "busybox crond && apache2-foreground"]

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
22

33
This currently is pretty minimal and uses:
44

5-
* apache-2.4.38
5+
* Apache httpd 2.4
6+
* BusyBox
67
* GD library
7-
* Unzip library
88
* php7.3
99
* php7.3-opcache
1010
* php7.3-acpu
1111
* php7.3-yaml
12-
* cron
13-
* vim editor
1412

1513
## Building the image from Dockerfile
1614

0 commit comments

Comments
 (0)