-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
133 lines (121 loc) · 4.71 KB
/
Copy pathDockerfile
File metadata and controls
133 lines (121 loc) · 4.71 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
125
126
127
128
129
130
131
132
133
FROM composer:2 AS composer
FROM php:8.4-fpm-alpine3.23
LABEL Maintainer="Ocasta" \
Description="Nginx PHP8.3 Wordpress Bedrock"
# Install runtime dependencies
RUN apk --no-cache add \
bash \
sed \
ghostscript \
php84-xml \
imagemagick \
ssmtp \
nginx \
nginx-mod-http-headers-more \
supervisor \
redis
# Install PHP extensions and PECL packages in a single layer
# https://make.wordpress.org/hosting/handbook/handbook/server-environment/#php-extensions
RUN set -ex; \
\
# Add build dependencies
apk add --no-cache --virtual .build-deps \
$PHPIZE_DEPS \
freetype-dev \
libjpeg-turbo-dev \
libpng-dev \
libzip-dev \
imagemagick-dev \
; \
\
# Configure and install PHP extensions
docker-php-ext-configure gd --with-freetype --with-jpeg; \
docker-php-ext-install -j "$(nproc)" \
bcmath \
exif \
gd \
mysqli \
opcache \
zip \
; \
\
# Install PECL extensions
pecl install -o -f imagick; \
pecl install ds-1.6.0; \
pecl install apfd-1.0.3; \
pecl install redis; \
\
# Enable all extensions
docker-php-ext-enable imagick apfd ds redis; \
\
# Identify and install runtime dependencies
runDeps="$( \
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \
| tr ',' '\n' \
| sort -u \
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
)"; \
apk add --virtual .wordpress-phpexts-rundeps $runDeps; \
\
# Clean up build dependencies
apk del .build-deps; \
rm -rf /tmp/pear ~/.pearrc
# Configure PHP settings in a single layer
RUN { \
# Opcache settings - https://secure.php.net/manual/en/opcache.installation.php
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 \
&& { \
# Error logging - https://wordpress.org/support/article/editing-wp-config-php/#configure-error-logging
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 'error_reporting = 0'; \
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
# Copy configuration files (cached layer - these change infrequently)
COPY config/nginx.conf /etc/nginx/http.d/default.conf
COPY config/nginx_headers.conf /etc/nginx/headers.conf
COPY config/fpm-pool.conf /usr/local/etc/php-fpm.d/zzz_custom.conf
COPY config/php.ini /usr/local/etc/php/conf.d/zzz_custom.ini
COPY config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# Install Bedrock with optimized Composer settings
# Use the Docker-official Composer so it runs against /usr/local/bin/php (which has tokenizer)
COPY --from=composer /usr/bin/composer /usr/local/bin/composer
# Sometime Bedrock don't have a release with the latest WP version and you have to use the dependabot commit
# RUN curl -L -o wordpress.tar.gz https://github.com/roots/bedrock/archive/84133b258efabbcbbd258137fd199fd1f742f3d6.tar.gz && tar --strip=1 -xzvf wordpress.tar.gz && rm wordpress.tar.gz && composer install --no-dev
RUN set -x && curl -L https://github.com/roots/bedrock/archive/refs/tags/1.31.1.tar.gz | tar -xz --strip=1 && \
composer install --no-dev --optimize-autoloader && \
composer clear-cache
# Install WordPress language packs
COPY scripts/install-language.sh /usr/local/bin/install-language.sh
RUN /usr/local/bin/install-language.sh ar de_DE es_ES fr_FR it_IT ja ko_KR pt_PT sv_SE zh_CN zh_TW && \
rm -f /usr/local/bin/install-language.sh
# Install Icelandic language pack (temporary hack until newer version available)
RUN cd /var/www/html/web/app/languages && \
curl -sSL https://downloads.wordpress.org/translation/core/4.9.28/is_IS.zip -O && \
unzip -q is_IS.zip && \
rm is_IS.zip
# Install Thai language pack (temporary hack until newer version available)
RUN cd /var/www/html/web/app/languages && \
curl -sSL https://downloads.wordpress.org/translation/core/5.8.13/th.zip -O && \
unzip -q th.zip && \
rm th.zip
# Create uploads directory and set permissions
RUN mkdir -p /var/www/html/web/app/uploads && \
chown -R www-data:www-data /var/www/html/web/app/uploads
# Copy scripts (most frequently changing files last for better cache)
COPY ./scripts/. /usr/local/bin/
# Expose nginx port
EXPOSE 80
ENTRYPOINT ["docker-entrypoint"]
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]