Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ Five different images for each PHP Version:

| Version | Latest Version | Monthly Builds | Alpine Version |
|:----------:|:----------------:|:--------------:|:----------------:|
| **8.6** ⚠ | **8.6.0beta2** | **yes** | **edge/testing** |
| **8.5** | **8.5.10** | **yes** | **edge** |
| **8.4** | **8.4.25** | **yes** | **edge** |
| **8.3** | **8.3.33** | **yes** | **edge** |
| **8.6** ⚠ | **8.6.0rc2** | **yes** | **edge/testing** |
| **8.5** | **8.5.11** | **yes** | **edge** |
| **8.4** | **8.4.26** | **yes** | **edge** |
| **8.3** | **8.3.35** | **yes** | **edge** |
| 8.2 | 8.2.31 | - | 3.22 |
| 8.1 | 8.1.31 | - | 3.19 |
| 8.0 | 8.0.30 | - | 3.16 |
Expand All @@ -82,9 +82,10 @@ Five different images for each PHP Version:
| 7.0 | 7.0.33 | - | 3.5 |
| 5.6 | 5.6.40 | - | 3.8 |

⚠ PHP 8.6 is a **pre-release** (beta). The images are meant for early testing only and do not
ship the `redis`, `memcached` and `yaml` extensions yet, since Alpine has not published them for
PHP 8.6.
⚠ PHP 8.6 is a **pre-release** (release candidate). The images are meant for early testing only. Alpine has not
published `imagick`, `memcached` and `yaml` for PHP 8.6 yet, so these three are built from their
upstream git repositories until it does. `imagick` is shipped disabled; see
[Imagick on PHP 8.6](docs/dockerfile.md#imagick-on-php-86).

:::info
PHP versions with monthly builds receive regular updates. Legacy versions (without monthly builds) are no longer supported.
Expand Down
2 changes: 0 additions & 2 deletions assets/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,9 @@ <h2 class="text-3xl font-bold tracking-tight sm:text-4xl">Pre-installed Extensio
<div class="rounded-md border border-slate-200 bg-slate-50 px-3 py-2 text-center font-mono text-sm">gettext</div>
<div class="rounded-md border border-slate-200 bg-slate-50 px-3 py-2 text-center font-mono text-sm">iconv</div>
<div class="rounded-md border border-slate-200 bg-slate-50 px-3 py-2 text-center font-mono text-sm">igbinary</div>
<div class="rounded-md border border-slate-200 bg-slate-50 px-3 py-2 text-center font-mono text-sm">imagick</div>
<div class="rounded-md border border-slate-200 bg-slate-50 px-3 py-2 text-center font-mono text-sm">intl</div>
<div class="rounded-md border border-slate-200 bg-slate-50 px-3 py-2 text-center font-mono text-sm">json</div>
<div class="rounded-md border border-slate-200 bg-slate-50 px-3 py-2 text-center font-mono text-sm">mbstring</div>
<div class="rounded-md border border-slate-200 bg-slate-50 px-3 py-2 text-center font-mono text-sm">mcrypt</div>
<div class="rounded-md border border-slate-200 bg-slate-50 px-3 py-2 text-center font-mono text-sm">memcached</div>
<div class="rounded-md border border-slate-200 bg-slate-50 px-3 py-2 text-center font-mono text-sm">mongodb</div>
<div class="rounded-md border border-slate-200 bg-slate-50 px-3 py-2 text-center font-mono text-sm">mysqli</div>
Expand Down
3 changes: 1 addition & 2 deletions config/php-8.2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ extensions:
- pdo_pgsql
- pdo_sqlite
- pear
# - pecl-imagick
- pecl-mcrypt
# imagick: not bundled. Install when needed: apk add php82-pecl-imagick
- pecl-memcached
- pecl-mongodb
- pecl-xdebug
Expand Down
3 changes: 1 addition & 2 deletions config/php-8.3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ extensions:
- pdo_pgsql
- pdo_sqlite
- pear
# - pecl-imagick
- pecl-mcrypt
# imagick: not bundled. Install when needed: apk add php83-pecl-imagick
- pecl-memcached
- pecl-mongodb
- pecl-xdebug
Expand Down
3 changes: 1 addition & 2 deletions config/php-8.4.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ extensions:
- pdo_pgsql
- pdo_sqlite
- pear
# - pecl-imagick
# - pecl-mcrypt
# imagick: not bundled. Install when needed: apk add php84-pecl-imagick
- pecl-memcached
- pecl-mongodb
- pecl-xdebug
Expand Down
5 changes: 2 additions & 3 deletions config/php-8.5.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,15 @@ extensions:
- mysqli
- mysqlnd
- openssl
# - opcache
# opcache: built into the PHP binary since 8.5, no package needed
- pcntl
- pdo
- pdo_dblib
- pdo_mysql
- pdo_pgsql
- pdo_sqlite
- pear
# - pecl-imagick
# - pecl-mcrypt
# imagick: not bundled. Install when needed: apk add php85-pecl-imagick
- pecl-memcached
- pecl-mongodb
- pecl-xdebug
Expand Down
34 changes: 31 additions & 3 deletions config/php-8.6.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,15 @@ extensions:
- mysqli
- mysqlnd
- openssl
# - opcache
# opcache: built into the PHP binary since 8.5, no package needed
- pcntl
- pdo
- pdo_dblib
- pdo_mysql
- pdo_pgsql
- pdo_sqlite
- pear
# - pecl-imagick
# - pecl-mcrypt
# imagick: see the `pecl` section below (compiled but not enabled)
# - pecl-memcached
- pecl-mongodb
- pecl-xdebug
Expand Down Expand Up @@ -65,6 +64,35 @@ pecl:
zend: True
config:
- xdebug.remote_port=9001
# The extensions below have no Alpine package for PHP 8.6 yet, and their latest pecl.php.net
# releases do not build on PHP 8.6 (XtOffsetOf / zval_dtor removed); the fix is only in git.
# Temporary: remove each entry and enable the matching `pecl-*` in `extensions` once Alpine
# publishes php86-pecl-imagick, php86-pecl-memcached and php86-pecl-yaml.
# imagick is only compiled, not enabled: the ImageMagick runtime is too large to ship by default.
# To use it: apk add imagemagick && echo "extension=imagick.so" > /etc/php86/conf.d/imagick.ini
- name: imagick
enable: False
source:
repository: https://github.com/Imagick/imagick.git
reference: 55ed2e9fda264395636a2e27e51f31673f5566ab
buildPackages:
- imagemagick-dev
- name: memcached
source:
repository: https://github.com/php-memcached-dev/php-memcached.git
reference: 0b52d3657140750fa0eddd20cdbfc6edc8fbdadd
buildPackages:
- libmemcached-dev
packages:
- libmemcached-libs
- name: yaml
source:
repository: https://github.com/php/pecl-file_formats-yaml.git
reference: a7a3b8680b8fbf0895fd63371a0ffc1305b1a5b8
buildPackages:
- yaml-dev
packages:
- yaml

composer:
packages:
Expand Down
15 changes: 13 additions & 2 deletions docs/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,18 @@ pecl:
- name: xdebug # required
version: 2.5.5 # optional - if not set, get the latest
install: False # optional - do not call pecl install
enable: False # optional - do not create the .ini file; the extension
# is left in the image but not loaded
zend: True # optional - if true, add as zend extension
config: # optional - if set, add extra config to php.ini
- xdebug.remote_port=9001 # for this extension
source: # optional - build from a git repository instead of
repository: https://...git # downloading the release from pecl.php.net
reference: (COMMIT/TAG) # optional - if not set, use the default branch
buildPackages: # optional - temporary packages needed only to build
- (NAME) # this extension
packages: # optional - permanent packages this extension needs
- (NAME) # at runtime

# Composer packages to be installed
composer:
Expand All @@ -157,12 +166,14 @@ composer:
- phpbcbf
- phpmd

# Temporary packages to be used to build the PECL packages
# Temporary packages to be used to build the PECL packages (generic; packages needed
# by a single extension go in `pecl[].buildPackages`)
peclBuildPackages:
- autoconf
- build-base

# Permanent packages to be installed in the image
# Permanent packages to be installed in the image (generic; packages needed
# by a single extension go in `pecl[].packages`)
additionalPackages:
- libssl1.1
- libcrypto1.1
Expand Down
22 changes: 16 additions & 6 deletions docs/dockerfile.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,7 @@ FROM byjg/php:8.3-cli

# Switch to root to install packages
USER root
RUN apk add --no-cache imagemagick imagemagick-dev

# Install PHP extensions if needed
RUN pecl install imagick && \
echo "extension=imagick.so" > /etc/php/conf.d/imagick.ini
RUN apk add --no-cache php83-pecl-imagick

# Switch back to app user
USER app
Expand All @@ -91,6 +87,21 @@ RUN composer install --no-dev --optimize-autoloader
Always switch back to the `app` user after installing packages. Running your application as root negates security benefits.
:::

#### Imagick on PHP 8.6

The PHP 8.6 images already contain a compiled `imagick.so`, but it is not enabled and the
ImageMagick runtime is not installed. There is nothing to compile; install the runtime and
enable the extension:

```dockerfile title="Dockerfile"
FROM byjg/php:8.6-cli

USER root
RUN apk add --no-cache imagemagick && \
echo "extension=imagick.so" > /etc/php86/conf.d/imagick.ini
USER app
```

### Full Configuration Example

```dockerfile title="Dockerfile"
Expand Down Expand Up @@ -150,7 +161,6 @@ ENV PHP_CONTROLLER=/index.php
# ENV DISABLEMODULE_msgpack=1
# ENV DISABLEMODULE_xdebug=1
# ENV DISABLEMODULE_yaml=1
# ENV DISABLEMODULE_mcrypt=1
# ENV DISABLEMODULE_mongodb=1

# Copy application with proper ownership
Expand Down
2 changes: 1 addition & 1 deletion docs/image-base.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ All base images come with over 45 PHP extensions pre-installed:

```
bcmath, Core, ctype, curl, date, dba, dom, exif, fileinfo, filter, ftp, gd, gettext,
hash, iconv, igbinary, intl, json, libxml, mbstring, mcrypt, memcached, mongodb,
hash, iconv, igbinary, intl, json, libxml, mbstring, memcached, mongodb,
mysqli, mysqlnd, openssl, pcntl, pcre, PDO, pdo_dblib, pdo_mysql, pdo_pgsql,
pdo_sqlite, Phar, posix, readline, redis, Reflection, session, shmop, SimpleXML,
soap, sockets, SPL, sqlite3, standard, tokenizer, xdebug, xml, xmlreader, xmlwriter,
Expand Down
9 changes: 6 additions & 3 deletions docs/security.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,16 +158,19 @@ To balance security with stability:

### Why Edge/Testing for PHP 8.6?

PHP 8.6 has not been released yet — Alpine ships it as `8.6.0_betaX` in the `edge/testing`
PHP 8.6 has not been released yet — Alpine ships it as `8.6.0_rcX` in the `edge/testing`
repository, which is the only Alpine repository carrying PHP 8.6 packages.

**Do not use PHP 8.6 in production** until it reaches a stable release. These images exist for:

- Early adoption and compatibility testing
- Previewing upcoming PHP features

Because PHP 8.6 is only available in `edge/testing`, a few extensions are **not** bundled in the
8.6 images yet: `redis`, `memcached` and `yaml`. They are added as soon as Alpine publishes them.
Because PHP 8.6 is only available in `edge/testing`, Alpine has not published every extension
for it yet. `imagick`, `memcached` and `yaml` are built from a pinned commit of their upstream
git repositories (see `pecl[].source` in `config/php-8.6.yml`), since their latest PECL releases
do not compile on PHP 8.6. They are replaced by the Alpine packages as soon as those are published.
`imagick` is compiled but not enabled; see [Imagick on PHP 8.6](dockerfile.md#imagick-on-php-86).

### Legacy PHP Versions (8.1 and older)

Expand Down
10 changes: 6 additions & 4 deletions templates/php-base.j2
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ apk --no-cache {% for rep in repositories %}--repository {{ rep }} {% endfor %}
mkdir -p /etc/php/conf.d

# Install PECL and additional packages
apk --no-cache {% for rep in repositories %}--repository {{ rep }} {% endfor %} add {% for pkg in additionalPackages %}{{ pkg }} {% endfor %}
apk --no-cache {% for rep in repositories %}--repository {{ rep }} {% endfor %} add --virtual .build php{{ version.suffix }}-pear php{{ version.suffix }}-dev {% for pkg in peclBuildPackages %}{{ pkg }} {% endfor %}
apk --no-cache {% for rep in repositories %}--repository {{ rep }} {% endfor %} add {% for pkg in additionalPackages %}{{ pkg }} {% endfor %}{% for ext in pecl %}{% for pkg in ext.packages | default([]) %}{{ pkg }} {% endfor %}{% endfor %}
apk --no-cache {% for rep in repositories %}--repository {{ rep }} {% endfor %} add --virtual .build php{{ version.suffix }}-pear php{{ version.suffix }}-dev {% for pkg in peclBuildPackages %}{{ pkg }} {% endfor %}{% for ext in pecl %}{% for pkg in ext.buildPackages | default([]) %}{{ pkg }} {% endfor %}{% endfor %}
sed -ie "s/ -n / /" /usr/bin/pecl
{% for ext in pecl -%}
{% if ext.install is not defined or ext.install %}yes "" | pecl install {{ ext.name }}{% if ext.version is defined %}-{{ ext.version }}{% endif %}{% endif %}
printf "{% if ext.zend %}zend_{% endif %}extension={{ ext.name }}.so{% for config in ext.config %}\n{{ config }}{% endfor %}\n" > /etc/php{{ version.suffix }}/conf.d/{{ ext.name }}.ini
{% if ext.install is not defined or ext.install %}{% if ext.source is defined %}git clone -q {{ ext.source.repository }} /tmp/pecl-{{ ext.name }}
(cd /tmp/pecl-{{ ext.name }} && git checkout -q {{ ext.source.reference | default('HEAD') }} && yes "" | pecl install package.xml)
rm -rf /tmp/pecl-{{ ext.name }}{% else %}yes "" | pecl install {{ ext.name }}{% if ext.version is defined %}-{{ ext.version }}{% endif %}{% endif %}{% endif %}
{% if ext.enable is not defined or ext.enable %}printf "{% if ext.zend %}zend_{% endif %}extension={{ ext.name }}.so{% for config in ext.config %}\n{{ config }}{% endfor %}\n" > /etc/php{{ version.suffix }}/conf.d/{{ ext.name }}.ini{% endif %}
{% endfor %}
apk del --no-cache .build

Expand Down
Loading