-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.template
104 lines (96 loc) · 4.2 KB
/
Dockerfile.template
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
{{
def is_alpine:
env.variant | index("alpine")
-}}
FROM php:{{ env.phpVersion }}-{{ env.variant }}
# persistent dependencies
{{ if is_alpine then ( -}}
RUN set -eux; \
apk add --no-cache \
# in theory, docker-entrypoint.sh is POSIX-compliant, but priority is a working, consistent image
bash \
# BusyBox sed is not sufficient for some of our sed expressions
sed \
;
{{ ) else ( -}}
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
; \
rm -rf /var/lib/apt/lists/*
{{ ) end -}}
# install the PHP extensions we need
RUN set -ex; \
docker-php-ext-install -j "$(nproc)" \
pdo pdo_mysql mysqli \
&& echo "post_max_size=80M" >> /usr/local/etc/php/conf.d/custom.ini \
&& echo "upload_max_filesize=20M" >> /usr/local/etc/php/conf.d/custom.ini \
# set recommended PHP.ini settings
# see https://secure.php.net/manual/en/opcache.installation.php
RUN set -eux; \
docker-php-ext-enable opcache; \
{ \
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'; \
} > /usr/local/etc/php/conf.d/opcache-recommended.ini
# Mirror WP Logging: https://wordpress.org/support/article/editing-wp-config-php/#configure-error-logging
RUN { \
# https://www.php.net/manual/en/errorfunc.constants.php
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/conf.d/error-logging.ini
{{ if env.variant == "apache" then ( -}}
RUN set -eux; \
a2enmod rewrite expires; \
\
# https://httpd.apache.org/docs/2.4/mod/mod_remoteip.html
a2enmod remoteip; \
{ \
echo 'RemoteIPHeader X-Forwarded-For'; \
# these IP ranges are reserved for "private" use and should thus *usually* be safe inside Docker
echo 'RemoteIPTrustedProxy 10.0.0.0/8'; \
echo 'RemoteIPTrustedProxy 172.16.0.0/12'; \
echo 'RemoteIPTrustedProxy 192.168.0.0/16'; \
echo 'RemoteIPTrustedProxy 169.254.0.0/16'; \
echo 'RemoteIPTrustedProxy 127.0.0.0/8'; \
} > /etc/apache2/conf-available/remoteip.conf; \
a2enconf remoteip; \
# https://github.com/docker-library/wordpress/issues/383#issuecomment-507886512
# (replace all instances of "%h" with "%a" in LogFormat)
find /etc/apache2 -type f -name '*.conf' -exec sed -ri 's/([[:space:]]*LogFormat[[:space:]]+"[^"]*)%h([^"]*")/\1%a\2/g' '{}' +; \
# Point Apache to phpCollab's web root
sed -ri -e 's!/var/www/html!/var/www/phpcollab!g' /etc/apache2/sites-available/*.conf; \
sed -ri -e 's!/var/www/!/var/www/phpcollab!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
{{ ) else "" end -}}
RUN set -eux; \
version={{ .upstream | @sh }}; \
sha1={{ .sha1 | @sh }}; \
\
curl -o phpcollab.tar.gz -fL "https://github.com/phpcollab/phpcollab/releases/download/v$version/phpcollab-v$version.tar.gz"; \
echo "$sha1 *phpcollab.tar.gz" | sha1sum -c -; \
\
# upstream tarballs include ./phpcollab/ so this gives us /var/www/phpcollab
tar -xzf phpcollab.tar.gz -C /var/www/; \
rm phpcollab.tar.gz; \
# Patching Installation.php setting the root (remove in v2.8.3)
sed -ri -e 's!"../!$this->appRoot . "/!g' /var/www/phpcollab/classes/Installation/Installation.php; \
\
chown -R www-data:www-data /var/www/phpcollab; \
# Create a location for the settings volume to be mounted to, and the setting.php to be linked from
mkdir -p /var/data/phpcollab; \
chown -R www-data:www-data /var/data/phpcollab
COPY docker-entrypoint.sh /usr/local/bin/
VOLUME ["/var/www/phpcollab/files", "/var/www/phpcollab/logo_clients", "/var/data/phpcollab"]
WORKDIR /var/www/phpcollab
ENTRYPOINT ["docker-entrypoint.sh"]
CMD {{ [ if env.variant == "apache" then "apache2-foreground" else "php-fpm" end ] | @json }}