Skip to content

Commit 9e155c9

Browse files
committed
feat: Add Trixie variant and update CI
This commit introduces support for the Trixie PHP variant in the Docker build process. It includes the necessary changes to the CI workflow `.github/workflows/docker-buildx.yml` to include `apache-trixie` in the matrix strategy and generate appropriate Docker tags. Additionally, a new Dockerfile `php8/apache-trixie/Dockerfile` is added to define the build for the Trixie variant.
1 parent 914d6fe commit 9e155c9

File tree

2 files changed

+137
-2
lines changed

2 files changed

+137
-2
lines changed

.github/workflows/docker-buildx.yml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
strategy:
1818
matrix:
1919
php_version: ["8.1", "8.2", "8.3", "8.4"]
20-
variant: ["apache-bookworm", "fpm-alpine"]
20+
variant: ["apache-trixie", "apache-bookworm", "fpm-alpine"]
2121
steps:
2222
- name: Checkout
2323
uses: actions/checkout@v5
@@ -42,12 +42,34 @@ jobs:
4242
- name: Set Dockerfile directory
4343
if: ${{ matrix.php_version == '8.1' || matrix.php_version == '8.2' || matrix.php_version == '8.3' || matrix.php_version == '8.4' }}
4444
run: echo "DOCKERFILE_DIR=php8" >> $GITHUB_ENV
45+
- name: Generate Docker tags
46+
id: tags
47+
run: |
48+
# Base tag with full variant name
49+
TAGS="hussainweb/drupal-base:php${{ matrix.php_version }}-${{ matrix.variant }}"
50+
51+
# For apache-trixie, add the short version tag (e.g., php8.4)
52+
if [ "${{ matrix.variant }}" = "apache-trixie" ]; then
53+
TAGS="${TAGS},hussainweb/drupal-base:php${{ matrix.php_version }}"
54+
fi
55+
56+
# For fpm-alpine, add the short -alpine tag (e.g., php8.4-alpine)
57+
if [ "${{ matrix.variant }}" = "fpm-alpine" ]; then
58+
TAGS="${TAGS},hussainweb/drupal-base:php${{ matrix.php_version }}-alpine"
59+
fi
60+
61+
# For the latest PHP version on apache-trixie, add the latest tag
62+
if [ "${{ matrix.php_version }}" = "8.4" ] && [ "${{ matrix.variant }}" = "apache-trixie" ]; then
63+
TAGS="${TAGS},hussainweb/drupal-base:latest"
64+
fi
65+
66+
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
4567
- name: Build and push Docker image for PHP ${{ matrix.php_version }}
4668
uses: docker/build-push-action@v6
4769
with:
4870
context: ${{ env.DOCKERFILE_DIR }}/${{ matrix.variant }}/
4971
push: ${{ github.event_name != 'pull_request' }}
50-
tags: hussainweb/drupal-base:php${{ matrix.php_version }}${{ matrix.variant == 'fpm-alpine' && '-alpine' || '' }}${{ matrix.php_version == '8.4' && ',hussainweb/drupal-base:latest' || '' }}
72+
tags: ${{ steps.tags.outputs.tags }}
5173
build-args: |
5274
PHP_VERSION=${{ matrix.php_version }}-${{ matrix.variant }}
5375
platforms: linux/amd64,linux/arm64

php8/apache-trixie/Dockerfile

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
ARG PHP_VERSION=8.4-apache-trixie
2+
# from https://www.drupal.org/docs/system-requirements/php-requirements
3+
FROM php:${PHP_VERSION}
4+
5+
# install the PHP extensions we need
6+
RUN set -eux; \
7+
\
8+
if command -v a2enmod; then \
9+
# https://github.com/drupal/drupal/blob/d91d8d0a6d3ffe5f0b6dde8c2fbe81404843edc5/.htaccess (references both mod_expires and mod_rewrite explicitly)
10+
a2enmod expires rewrite; \
11+
fi; \
12+
\
13+
apt-get update; \
14+
apt-get install -y --no-install-recommends \
15+
git \
16+
unzip \
17+
sendmail \
18+
mariadb-client \
19+
; \
20+
\
21+
savedAptMark="$(apt-mark showmanual)"; \
22+
\
23+
apt-get update; \
24+
apt-get install -y --no-install-recommends \
25+
libavif-dev \
26+
libbz2-dev \
27+
libfreetype6-dev \
28+
libicu-dev \
29+
libjpeg-dev \
30+
libmemcached-dev \
31+
libpng-dev \
32+
libpq-dev \
33+
libwebp-dev \
34+
libyaml-dev \
35+
libzip-dev \
36+
; \
37+
\
38+
docker-php-ext-configure gd \
39+
--with-avif \
40+
--with-freetype \
41+
--with-jpeg=/usr \
42+
--with-webp \
43+
; \
44+
\
45+
docker-php-ext-install -j "$(nproc)" \
46+
bcmath \
47+
bz2 \
48+
exif \
49+
gd \
50+
intl \
51+
opcache \
52+
pcntl \
53+
pdo_mysql \
54+
pdo_pgsql \
55+
sockets \
56+
zip \
57+
; \
58+
\
59+
pecl install \
60+
apcu \
61+
memcached \
62+
redis \
63+
yaml \
64+
; \
65+
\
66+
docker-php-ext-enable \
67+
apcu \
68+
memcached \
69+
redis \
70+
yaml \
71+
; \
72+
\
73+
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
74+
apt-mark auto '.*' > /dev/null; \
75+
apt-mark manual $savedAptMark; \
76+
ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \
77+
| awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); printf "*%s\n", so }' \
78+
| sort -u \
79+
| xargs -r dpkg-query -S \
80+
| cut -d: -f1 \
81+
| sort -u \
82+
| xargs -rt apt-mark manual; \
83+
\
84+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
85+
rm -rf /var/lib/apt/lists/*
86+
87+
# set recommended PHP.ini settings
88+
# see https://secure.php.net/manual/en/opcache.installation.php
89+
RUN { \
90+
echo 'opcache.memory_consumption=128'; \
91+
echo 'opcache.interned_strings_buffer=8'; \
92+
echo 'opcache.max_accelerated_files=4000'; \
93+
echo 'opcache.revalidate_freq=60'; \
94+
} > /usr/local/etc/php/conf.d/opcache-recommended.ini; \
95+
# Remove the memory limit for the CLI only.
96+
echo 'memory_limit = -1' > /usr/local/etc/php/php-cli.ini; \
97+
# Change docroot since we use Composer Drupal project.
98+
sed -ri -e 's!/var/www/html!/var/www/html/web!g' /etc/apache2/sites-available/*.conf; \
99+
sed -ri -e 's!/var/www!/var/www/html/web!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
100+
101+
102+
# https://www.drupal.org/node/3298550
103+
# Drupal now recommends sites enable PHP output buffering by default, if PHP is run as a server module
104+
# e.g. with Apache's mod_php
105+
RUN { \
106+
echo 'output_buffering=true'; \
107+
} > /usr/local/etc/php/conf.d/docker-php-drupal-recommended.ini
108+
109+
WORKDIR /var/www/html
110+
111+
ENV COMPOSER_ALLOW_SUPERUSER=1
112+
COPY --from=composer:2 /usr/bin/composer /usr/local/bin/
113+
ENV PATH=${PATH}:/var/www/html/vendor/bin

0 commit comments

Comments
 (0)