Skip to content

Commit 502e627

Browse files
committed
feat: add php.ini envs from clevyr/docker-php
1 parent fcea943 commit 502e627

File tree

2 files changed

+52
-10
lines changed

2 files changed

+52
-10
lines changed

Dockerfile

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,44 @@ FROM wordpress:cli-${CLI_VERSION}-php${PHP_VERSION} AS wp-cli-source
1111

1212
FROM wordpress:${WORDPRESS_VERSION}-php${PHP_VERSION}-${FLAVOR} AS base
1313

14-
# Disable short tags
15-
RUN echo 'short_open_tag=Off' >> /usr/local/etc/php/conf.d/custom-php.ini
16-
1714
COPY --from=wp-cli-source /usr/local/bin/wp /usr/local/bin/wp
18-
RUN chmod +x /usr/local/bin/wp
19-
20-
RUN mkdir -p /var/www/.wp-cli/cache && \
21-
chown -R www-data:www-data /var/www/.wp-cli
22-
2315
ARG WP_CLI_ALLOW_ROOT=1
2416
ENV WP_CLI_ALLOW_ROOT=$WP_CLI_ALLOW_ROOT
2517

18+
RUN <<EOT
19+
set -eux
20+
21+
mkdir -p /var/www/.wp-cli/cache
22+
chown -R www-data:www-data /var/www/.wp-cli
23+
24+
cd "$PHP_INI_DIR"
25+
26+
sed -ri \
27+
-e 's/^;?(max_execution_time).*/\1 = ${PHP_MAX_EXECUTION_TIME}/' \
28+
-e 's/^;?(max_input_vars).*/\1 = ${PHP_MAX_INPUT_VARS}/' \
29+
-e 's/^;?(memory_limit).*/\1 = ${PHP_MEMORY_LIMIT}/' \
30+
-e 's/^;?(post_max_size).*/\1 = ${PHP_POST_MAX_SIZE}/' \
31+
-e 's/^;?(upload_max_filesize).*/\1 = ${PHP_UPLOAD_MAX_FILESIZE}/' \
32+
-e 's/^;?(max_file_uploads).*/\1 = ${PHP_MAX_FILE_UPLOADS}/' \
33+
-e 's/^;?(expose_php).*/\1 = Off/' \
34+
php.ini-production
35+
36+
ln -s php.ini-production php.ini
37+
EOT
38+
39+
ONBUILD ARG PHP_MAX_EXECUTION_TIME
40+
ONBUILD ENV PHP_MAX_EXECUTION_TIME=${PHP_MAX_EXECUTION_TIME:-30}
41+
ONBUILD ARG PHP_MAX_INPUT_VARS
42+
ONBUILD ENV PHP_MAX_INPUT_VARS=${PHP_MAX_INPUT_VARS:-1000}
43+
ONBUILD ARG PHP_MEMORY_LIMIT
44+
ONBUILD ENV PHP_MEMORY_LIMIT=${PHP_MEMORY_LIMIT:-256M}
45+
ONBUILD ARG PHP_POST_MAX_SIZE
46+
ONBUILD ENV PHP_POST_MAX_SIZE=${PHP_POST_MAX_SIZE:-32M}
47+
ONBUILD ARG PHP_UPLOAD_MAX_FILESIZE
48+
ONBUILD ENV PHP_UPLOAD_MAX_FILESIZE=${PHP_UPLOAD_MAX_FILESIZE:-8M}
49+
ONBUILD ARG PHP_MAX_FILE_UPLOADS
50+
ONBUILD ENV PHP_MAX_FILE_UPLOADS=${PHP_MAX_FILE_UPLOADS:-20}
51+
2652
COPY --from=ext-installer /usr/bin/install-php-extensions /usr/local/bin/install-php-extensions
2753

2854
ARG PHP_EXTENSIONS

README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,28 @@
22

33
This repo builds base Docker base images for WordPress.
44

5-
## Build
5+
## Build Arguments
6+
7+
The following variables can be only be configured at build.
68

7-
### Arguments
89
| Build Arg | Description |
910
|---------------------|------------------------------------------------------------------------------------------------------------------------------------------------|
1011
| `WORDPRESS_VERSION` | WordPress version |
1112
| `PHP_VERSION` | PHP version |
1213
| `PHP_EXTENSIONS` | Additional extensions to install (using [`mlocati/docker-php-extension-installer`](https://github.com/mlocati/docker-php-extension-installer)) |
1314
| `FLAVOR` | Base image type. One of `apache`, `fpm-alpine`, or `cli` |
15+
16+
## Runtime Configuration
17+
18+
### PHP Configuration
19+
20+
The following variables can be configured at build (Typically with an `ARG` in the `Dockerfile`) or during runtime (With environment variables).
21+
22+
| Build Arg | Description | Default |
23+
|---------------------------|----------------------------------------------------------------------------------------------------------|---------|
24+
| `PHP_MAX_EXECUTION_TIME` | See [`max_execution_time`](https://www.php.net/manual/en/info.configuration.php#ini.max-execution-time). | `30` |
25+
| `PHP_MAX_INPUT_VARS` | See [`max_input_vars`](https://www.php.net/manual/en/info.configuration.php#ini.max-input-vars). | `1000` |
26+
| `PHP_MEMORY_LIMIT` | See [`memory_limit`](https://www.php.net/manual/en/ini.core.php#ini.memory-limit). | `256M` |
27+
| `PHP_POST_MAX_SIZE` | See [`post_max_size`](https://www.php.net/manual/en/ini.core.php#ini.post-max-size). | `32M` |
28+
| `PHP_UPLOAD_MAX_FILESIZE` | See [`upload_max_filesize`](https://www.php.net/manual/en/ini.core.php#ini.upload-max-filesize). | `8M` |
29+
| `PHP_MAX_FILE_UPLOADS` | See [`max_file_uploads`](https://www.php.net/manual/en/ini.core.php#ini.max-file-uploads). | `20` |

0 commit comments

Comments
 (0)