-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathContainerfile.apache
More file actions
124 lines (108 loc) · 4.21 KB
/
Copy pathContainerfile.apache
File metadata and controls
124 lines (108 loc) · 4.21 KB
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
ARG FREEBSD_RELEASE
ARG APACHEVER
ARG PHPVER
FROM ghcr.io/appjail-makejails/apache:${FREEBSD_RELEASE}-${APACHEVER}-php${PHPVER}
ARG NO_PKGCLEAN
LABEL org.opencontainers.image.title="WordPress" \
org.opencontainers.image.description="State-of-the-art semantic personal publishing platform" \
org.opencontainers.image.source="https://github.com/AppJail-makejails/wordpress" \
org.opencontainers.image.url="https://github.com/AppJail-makejails/wordpress" \
org.opencontainers.image.vendor="DtxdF" \
org.opencontainers.image.authors="Jesús Daniel Colmenares Oviedo <dtxdf@disroot.org>"
ARG PHPVER
RUN set -xe; \
\
pkg update; \
pkg install -U wordpress gsed bash gtar gawk; \
\
if [ -z "${NO_PKGCLEAN}" ]; then \
pkg clean -a; \
rm -rf /var/cache/pkg/*; \
fi; \
rm -rf /var/db/pkg/repos/*; \
\
php_version=`php -r 'echo PHP_VERSION;' | sed -Ee 's/^([0-9]+)\.([0-9]+)\.[0-9]+$/\1\2/'`; \
\
if [ "${php_version}" != "${PHPVER}" ]; then \
echo "Installed PHP version is different from what expected ( ${php_version} != ${PHPVER} )"; \
exit 1; \
fi
# set recommended PHP.ini settings
# see https://secure.php.net/manual/en/opcache.installation.php
RUN set -eux; \
{ \
echo 'opcache.memory_consumption=128'; \
echo 'opcache.interned_strings_buffer=8'; \
echo 'opcache.max_accelerated_files=4000'; \
echo 'opcache.revalidate_freq=2'; \
} > "/usr/local/etc/php/opcache-recommended.ini"
# https://wordpress.org/support/article/editing-wp-config-php/#configure-error-logging
RUN set -eux; \
{ \
# 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'; \
} > "/usr/local/etc/php/error-logging.ini"
RUN set -eux; \
sed -i '' \
-e '/LoadModule rewrite_module/s/^#//' \
-e '/LoadModule expires_module/s/^#//' \
-e '/LoadModule remoteip_module/s/^#//' \
/usr/local/etc/apache24/httpd.conf; \
{ \
echo 'RemoteIPHeader X-Forwarded-For'; \
# these IP ranges are reserved for "private" use and should thus *usually* be safe inside Docker
echo 'RemoteIPInternalProxy 10.0.0.0/8'; \
echo 'RemoteIPInternalProxy 172.16.0.0/12'; \
echo 'RemoteIPInternalProxy 192.168.0.0/16'; \
echo 'RemoteIPInternalProxy 169.254.0.0/16'; \
echo 'RemoteIPInternalProxy 127.0.0.0/8'; \
} > /usr/local/etc/apache24/Includes/remoteip.conf; \
find /usr/local/etc/apache24 -type f -name '*.conf' -exec gsed -ri 's/([[:space:]]*LogFormat[[:space:]]+"[^"]*)%h([^"]*")/\1%a\2/g' '{}' +
RUN set -eux; \
\
# https://wordpress.org/support/article/htaccess/
[ ! -e /usr/src/wordpress/.htaccess ]; \
{ \
echo '# BEGIN WordPress'; \
echo ''; \
echo 'RewriteEngine On'; \
echo 'RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]'; \
echo 'RewriteBase /'; \
echo 'RewriteRule ^index\.php$ - [L]'; \
echo 'RewriteCond %{REQUEST_FILENAME} !-f'; \
echo 'RewriteCond %{REQUEST_FILENAME} !-d'; \
echo 'RewriteRule . /index.php [L]'; \
echo ''; \
echo '# END WordPress'; \
} > /usr/local/www/wordpress/.htaccess; \
\
mkdir -p /usr/local/www/wordpress/wp-content/cache; \
\
chown -R www:www /usr/local/www/wordpress; \
\
mkdir -p /usr/local/www/html; \
chown www:www /usr/local/www/html; \
chmod 755 /usr/local/www/html; \
\
rm -rf /usr/local/www/apache24/data; \
ln -s /usr/local/www/html /usr/local/www/apache24/data; \
\
rm -f /usr/local/www/wordpress/wp-config.php
VOLUME /usr/local/www/html
COPY wp-config-oci.php /usr/local/www/wordpress
COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh
# https://github.com/docker-library/wordpress/issues/969
RUN ln -svf entrypoint.sh /ensure-installed.sh
WORKDIR /usr/local/www/html
ENTRYPOINT ["/entrypoint.sh"]
CMD ["httpd-foreground"]