-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.buster
144 lines (139 loc) · 5.56 KB
/
Dockerfile.buster
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
ARG VERSION
ARG VARIANT
FROM --platform=${TARGETPLATFORM} php:${VERSION}-${VARIANT}-buster
ARG TARGETPLATFORM
ENV DEBIAN_FRONTEND noninteractive
# Persistent dependencies
RUN set -eux; \
\
# https://serverfault.com/questions/633394/php-configure-not-finding-ldap-header-libraries
if [ ${TARGETPLATFORM} = linux/386 ]; then \
ln -s /usr/lib/i386-linux-gnu/libldap.so /usr/lib/libldap.so; \
ln -s /usr/lib/i386-linux-gnu/liblber.so /usr/lib/liblber.so; \
fi; \
# https://github.com/docker/buildx/issues/495#issuecomment-772267281
if [ ${TARGETPLATFORM} = linux/arm64 || ${TARGETPLATFORM} = linux/arm/v7 ]; then \
ln -s /usr/bin/dpkg-split /usr/sbin; \
ln -s /usr/bin/dpkg-deb /usr/sbin; \
ln -s /bin/tar /usr/sbin; \
ln -s /bin/rm /usr/sbin; \
fi; \
apt-get update; \
apt-get install -y --no-install-recommends \
# Ghostscript is required for rendering PDF previews
ghostscript \
; \
rm -rf /var/lib/apt/lists/*
# Install dependencies
RUN set -ex; \
\
# https://github.com/docker/buildx/issues/495#issuecomment-772267281
if [ ${TARGETPLATFORM} = linux/arm64 || ${TARGETPLATFORM} = linux/arm/v7 ]; then \
ln -s /usr/bin/dpkg-split /usr/sbin; \
ln -s /usr/bin/dpkg-deb /usr/sbin; \
ln -s /bin/tar /usr/sbin; \
ln -s /bin/rm /usr/sbin; \
fi; \
\
savedAptMark="$(apt-mark showmanual)"; \
\
apt-get update; \
apt-get install -y --no-install-recommends \
libbz2-dev libicu-dev libldap2-dev libldb-dev libpq-dev libxslt1-dev libzip-dev libc-client-dev \
libkrb5-dev libfreetype6-dev libjpeg62-turbo-dev libpng-dev libwebp-dev libxpm-dev \
libmagickwand-dev libmemcached-dev zlib1g-dev libzstd-dev libedit-dev \
; \
docker-php-ext-configure gd --with-freetype --with-jpeg --with-xpm --with-webp; \
docker-php-ext-configure imap --with-imap --with-imap-ssl --with-kerberos; \
docker-php-ext-install -j$(nproc) \
bz2 bcmath calendar exif gd gettext imap intl ldap mysqli pcntl pdo_mysql pdo_pgsql \
shmop sockets sysvmsg sysvsem sysvshm xsl zip readline; \
docker-php-ext-enable opcache; \
# imagick
# use github version for now until release from https://pecl.php.net/get/imagick is ready for PHP 8
# https://github.com/Imagick/imagick/issues/331#issuecomment-779190777
# https://github.com/Imagick/imagick/issues/331#issuecomment-785284870
mkdir -p /usr/src/php/ext/imagick; \
curl -fsSL https://github.com/Imagick/imagick/archive/06116aa24b76edaf6b1693198f79e6c295eda8a9.tar.gz | tar xvz -C "/usr/src/php/ext/imagick" --strip 1; \
docker-php-ext-install -j$(nproc) imagick; \
rm -rf /usr/src/php/ext/imagick; \
# apcu igbinary msgpack xdebug
echo 'no' | pecl install apcu; \
pecl install igbinary; \
pecl install msgpack; \
pecl install xdebug; \
docker-php-ext-enable apcu igbinary msgpack xdebug; \
# redis memcached
echo 'yes\nyes\nyes' | pecl install redis; \
echo 'no\nno\nno\nyes\nno\nyes\nno\nyes\nyes' | pecl install memcached; \
docker-php-ext-enable redis memcached; \
\
# clean
pecl clear-cache; \
docker-php-source delete; \
apt-get -y remove --purge \
libbz2-dev libicu-dev libldap2-dev libpq-dev libxslt1-dev libzip-dev libc-client-dev libkrb5-dev \
libfreetype6-dev libjpeg62-turbo-dev libpng-dev libwebp-dev libxpm-dev libmagickwand-dev \
libmemcached-dev zlib1g-dev libzstd-dev libedit-dev \
; \
\
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
ENV MAX_EXECUTION_TIME 600
ENV MEMORY_LIMIT 512M
ENV UPLOAD_LIMIT 2048K
RUN set -ex; \
\
{ \
echo ''; \
echo 'TLS_REQCERT never'; \
} >> /etc/openldap/ldap.conf; \
\
{ \
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'; \
} > $PHP_INI_DIR/conf.d/opcache-recommended.ini; \
\
{ \
echo 'session.cookie_httponly=1'; \
echo 'session.use_strict_mode=1'; \
} > $PHP_INI_DIR/conf.d/session-strict.ini; \
\
{ \
echo 'allow_url_fopen=Off'; \
echo 'max_execution_time=${MAX_EXECUTION_TIME}'; \
echo 'max_input_vars=10000'; \
echo 'memory_limit=${MEMORY_LIMIT}'; \
echo 'post_max_size=${UPLOAD_LIMIT}'; \
echo 'upload_max_filesize=${UPLOAD_LIMIT}'; \
} > $PHP_INI_DIR/conf.d/phpmyadmin-misc.ini; \
\
# https://wordpress.org/support/article/editing-wp-config-php/#configure-error-logging
{ \
# https://www.php.net/manual/en/errorfunc.constants.php
# https://github.com/docker-library/wordpress/issues/420#issuecomment-517839670
echo 'error_reporting = E_ERROR | E_WARNING | E_PARSE | E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_COMPILE_WARNING | E_RECOVERABLE_ERROR'; \
echo 'display_errors = Off'; \
echo 'display_startup_errors = Off'; \
echo 'log_errors = On'; \
echo 'error_log = /dev/stderr'; \
echo 'log_errors_max_len = 1024'; \
echo 'ignore_repeated_errors = On'; \
echo 'ignore_repeated_source = Off'; \
echo 'html_errors = Off'; \
} > $PHP_INI_DIR/conf.d/error-logging.ini