Skip to content

Commit 904405d

Browse files
authored
Update docker files for PHP 8.4 (#74)
* Update docker files to use debian current stable 'Trixie' and PHP 8.4 * Allow build and test workflow to be manually triggered * Update depreciated action * Fix the Github CI badge * Update the build regex * Update the readme with new tags * Exclude bullseye+php8.4 The issue was that Bullseye's older packages cause extremely long build times (compiling libavif/aom codec dependencies from source). * Update the docker compose command to use new syntax GitHub Actions runners no longer have docker-compose (v1) installed by default. They now use Docker Compose v2, which uses the command docker compose (with a space instead of hyphen). * Update to MySQL 8.1 * Added multiple retries for build and push In testing sometimes these would fail due to external conditions, this makes the build a bit more resilient * Revert "Allow build and test workflow to be manually triggered" This reverts commit 6c91dde.
1 parent 5eff595 commit 904405d

File tree

17 files changed

+521
-31
lines changed

17 files changed

+521
-31
lines changed

.github/actions/build-test/action.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ runs:
2626
BUILD_DIR: src/${{ inputs.php }}/${{ inputs.distro }}/${{ inputs.os }}
2727
DOCKER_BUILDKIT: 1
2828
COMPOSE_DOCKER_CLI_BUILD: 1
29-
run: docker-compose build sut
29+
run: docker compose build sut
3030
shell: bash
3131

3232
- name: Get Composer Cache Directory
@@ -38,7 +38,7 @@ runs:
3838
- name: Get Framework Version
3939
id: framework
4040
run : |
41-
if [[ "${{ inputs.php }}" == "8.1" ]]; then echo "version=4" >> $GITHUB_OUTPUT ; else echo "version=5" >> $GITHUB_OUTPUT; fi
41+
if [[ "${{ inputs.php }}" == "8.1" ]]; then echo "version=4" >> $GITHUB_OUTPUT ; elif [[ "${{ inputs.php }}" == "8.4" ]]; then echo "version=6" >> $GITHUB_OUTPUT; else echo "version=5" >> $GITHUB_OUTPUT; fi
4242
shell: bash
4343

4444
- name: Cache Composer Downloads
@@ -53,10 +53,10 @@ runs:
5353
env:
5454
COMPOSER_HOME: ${{ steps.composer-data.outputs.dir }}
5555
run: |
56-
docker-compose run --rm composer config -g platform.php ${{ inputs.php }}
57-
docker-compose run --rm composer config -g platform.ext-intl 1
58-
docker-compose run --rm composer config -g --no-interaction allow-plugins.composer/installers true
59-
docker-compose run --rm composer create-project --no-interaction --no-dev silverstripe/installer . ^${{ steps.framework.outputs.version }}
56+
docker compose run --rm composer config -g platform.php ${{ inputs.php }}
57+
docker compose run --rm composer config -g platform.ext-intl 1
58+
docker compose run --rm composer config -g --no-interaction allow-plugins.composer/installers true
59+
docker compose run --rm composer create-project --no-interaction --no-dev silverstripe/installer . ^${{ steps.framework.outputs.version }}
6060
shell: bash
6161

6262
- name: Run tests
@@ -66,12 +66,12 @@ runs:
6666
PLATFORM: ${{ inputs.platform }}
6767
DOCKER_BUILDKIT: 1
6868
COMPOSE_DOCKER_CLI_BUILD: 1
69-
run: docker-compose run sut
69+
run: docker compose run sut
7070
shell: bash
7171

7272
- name: The job has failed
7373
if: ${{ failure() }}
7474
run: |
75-
docker-compose logs
75+
docker compose logs
7676
shell: bash
7777

.github/workflows/build-and-test.yml

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,20 @@ jobs:
2424
strategy:
2525
fail-fast: false
2626
matrix:
27-
os: [bookworm, bullseye, alpine]
28-
php: ['8.1', '8.2', '8.3']
27+
os: [trixie, bookworm, bullseye, alpine]
28+
php: ['8.1', '8.2', '8.3', '8.4']
2929
distro: [apache, fpm, cli]
3030
exclude:
3131
- os: alpine
3232
distro: apache
33+
- os: trixie
34+
php: '8.1'
35+
- os: trixie
36+
php: '8.2'
37+
- os: trixie
38+
php: '8.3'
39+
- os: bullseye
40+
php: '8.4'
3341
steps:
3442
- name: Checkout repository
3543
uses: actions/checkout@v3
@@ -48,7 +56,33 @@ jobs:
4856
--volume ${REGISTRY_PATH}:/var/lib/registry \
4957
--name registry registry:2
5058
51-
- name: Build silverstripe docker image
59+
- name: Build silverstripe docker image (attempt 1)
60+
id: build_attempt_1
61+
continue-on-error: true
62+
uses: docker/build-push-action@v3.2.0
63+
with:
64+
context: src/${{ matrix.php }}/${{ matrix.distro }}/${{ matrix.os }}
65+
platforms: linux/amd64,linux/arm64
66+
cache-from: type=gha,scope=${{ matrix.php }}-${{ matrix.distro }}-${{ matrix.os }}
67+
cache-to: type=gha,scope=${{ matrix.php }}-${{ matrix.distro }}-${{ matrix.os }}
68+
push: true
69+
tags: ${{ env.IMAGE_PREFIX }}:${{ matrix.php }}-${{ matrix.distro }}-${{ matrix.os }}-test
70+
71+
- name: Build silverstripe docker image (attempt 2)
72+
id: build_attempt_2
73+
if: steps.build_attempt_1.outcome == 'failure'
74+
continue-on-error: true
75+
uses: docker/build-push-action@v3.2.0
76+
with:
77+
context: src/${{ matrix.php }}/${{ matrix.distro }}/${{ matrix.os }}
78+
platforms: linux/amd64,linux/arm64
79+
cache-from: type=gha,scope=${{ matrix.php }}-${{ matrix.distro }}-${{ matrix.os }}
80+
cache-to: type=gha,scope=${{ matrix.php }}-${{ matrix.distro }}-${{ matrix.os }}
81+
push: true
82+
tags: ${{ env.IMAGE_PREFIX }}:${{ matrix.php }}-${{ matrix.distro }}-${{ matrix.os }}-test
83+
84+
- name: Build silverstripe docker image (attempt 3)
85+
if: steps.build_attempt_2.outcome == 'failure'
5286
uses: docker/build-push-action@v3.2.0
5387
with:
5488
context: src/${{ matrix.php }}/${{ matrix.distro }}/${{ matrix.os }}
@@ -62,7 +96,7 @@ jobs:
6296
run: docker stop registry
6397

6498
- name: Upload Docker registry data for testing
65-
uses: actions/upload-artifact@v3
99+
uses: actions/upload-artifact@v4
66100
with:
67101
name: docker-registry-data-${{ matrix.php }}-${{ matrix.distro }}-${{ matrix.os }}
68102
path: ${{ env.REGISTRY_PATH }}/
@@ -74,12 +108,20 @@ jobs:
74108
strategy:
75109
matrix:
76110
platform: [linux/amd64, linux/arm64]
77-
os: [bookworm, bullseye, alpine]
78-
php: ['8.1', '8.2', '8.3']
111+
os: [trixie, bookworm, bullseye, alpine]
112+
php: ['8.1', '8.2', '8.3', '8.4']
79113
distro: [apache, fpm, cli]
80114
exclude:
81115
- os: alpine
82116
distro: apache
117+
- os: trixie
118+
php: '8.1'
119+
- os: trixie
120+
php: '8.2'
121+
- os: trixie
122+
php: '8.3'
123+
- os: bullseye
124+
php: '8.4'
83125
env:
84126
PLATFORM: ${{ matrix.platform }}
85127

@@ -88,7 +130,7 @@ jobs:
88130
uses: actions/checkout@v3
89131

90132
- name: Download Docker registry data from build job
91-
uses: actions/download-artifact@v3
133+
uses: actions/download-artifact@v4
92134
with:
93135
name: docker-registry-data-${{ matrix.php }}-${{ matrix.distro }}-${{ matrix.os }}
94136
path: ${{ env.REGISTRY_PATH }}

.github/workflows/publish.yml

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,28 @@ jobs:
2020
strategy:
2121
fail-fast: false
2222
matrix:
23-
os: [bookworm, bullseye, alpine]
24-
php: ['8.1', '8.2', '8.3']
23+
os: [trixie, bookworm, bullseye, alpine]
24+
php: ['8.1', '8.2', '8.3', '8.4']
2525
distro: [apache, fpm, cli]
2626
exclude:
2727
- os: alpine
2828
distro: apache
29+
- os: trixie
30+
php: '8.1'
31+
- os: trixie
32+
php: '8.2'
33+
- os: trixie
34+
php: '8.3'
35+
- os: bullseye
36+
php: '8.4'
2937
include:
3038
- os: bookworm
3139
additional_distro: true
3240
- os: bookworm
3341
distro: apache
3442
additional_php: true
3543
- os: bookworm
36-
php: 8.3
44+
php: 8.4
3745
distro: apache
3846
latest: true
3947
steps:
@@ -65,7 +73,35 @@ jobs:
6573
username: ${{ secrets.DOCKERHUB_USERNAME }}
6674
password: ${{ secrets.DOCKERHUB_TOKEN }}
6775

68-
- name: Build and push
76+
- name: Build and push (attempt 1)
77+
id: build_attempt_1
78+
continue-on-error: true
79+
uses: docker/build-push-action@v4
80+
with:
81+
context: src/${{ matrix.php }}/${{ matrix.distro }}/${{ matrix.os }}
82+
platforms: linux/amd64,linux/arm64
83+
push: true
84+
tags: ${{ steps.meta.outputs.tags }}
85+
labels: ${{ steps.meta.outputs.labels }}
86+
cache-from: type=gha,scope=${{ matrix.php }}-${{ matrix.distro }}-${{ matrix.os }}
87+
cache-to: type=gha,scope=${{ matrix.php }}-${{ matrix.distro }}-${{ matrix.os }}
88+
89+
- name: Build and push (attempt 2)
90+
id: build_attempt_2
91+
if: steps.build_attempt_1.outcome == 'failure'
92+
continue-on-error: true
93+
uses: docker/build-push-action@v4
94+
with:
95+
context: src/${{ matrix.php }}/${{ matrix.distro }}/${{ matrix.os }}
96+
platforms: linux/amd64,linux/arm64
97+
push: true
98+
tags: ${{ steps.meta.outputs.tags }}
99+
labels: ${{ steps.meta.outputs.labels }}
100+
cache-from: type=gha,scope=${{ matrix.php }}-${{ matrix.distro }}-${{ matrix.os }}
101+
cache-to: type=gha,scope=${{ matrix.php }}-${{ matrix.distro }}-${{ matrix.os }}
102+
103+
- name: Build and push (attempt 3)
104+
if: steps.build_attempt_2.outcome == 'failure'
69105
uses: docker/build-push-action@v4
70106
with:
71107
context: src/${{ matrix.php }}/${{ matrix.distro }}/${{ matrix.os }}

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ endif
77

88
IMAGE_NAME ?= silverstripe-web
99
IMAGE_PREFIX ?= brettt89
10-
IMAGE_TAG ?= $(if $(filter %,$(ARG)),$(ARG),8.3-apache-bookworm)
10+
IMAGE_TAG ?= $(if $(filter %,$(ARG)),$(ARG),8.4-apache-bookworm)
1111
COMMIT ?= commit-id
1212
IMAGE ?= ${IMAGE_PREFIX}/${IMAGE_NAME}:${IMAGE_TAG}
1313
BUILD_DIR ?= src/$(subst -,/,$(IMAGE_TAG))
@@ -38,7 +38,7 @@ update:
3838
./build/update.sh
3939

4040
build:
41-
./build/build-regex.sh $(if $(filter %,$(ARG)),$(ARG),8.3-apache-bookworm)
41+
./build/build-regex.sh $(if $(filter %,$(ARG)),$(ARG),8.4-apache-bookworm)
4242

4343
build-image:
4444
IMAGE_TAG=${IMAGE_TAG} ./build/build-image.sh

README.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
- ![GitHub CI](https://github.com/brettt89/silverstripe-docker/workflows/GitHub%20CI/badge.svg?branch=master)
2-
- ![Release](https://github.com/brettt89/silverstripe-docker/workflows/Release/badge.svg?branch=master)
1+
- ![Build and test Docker images](https://github.com/brettt89/silverstripe-docker/actions/workflows/build-and-test.yml/badge.svg?branch=master)
2+
- ![Release](https://github.com/brettt89/silverstripe-docker/actions/workflows/publish.yml/badge.svg?branch=master)
33

44
# Quick reference
55

@@ -11,9 +11,15 @@
1111

1212
# Supported Tags and respective `Dockerfile` links
1313

14-
> Due to [Silverstripe's supported php versions](https://docs.silverstripe.org/en/4/getting_started/server_requirements/#php-support) not including 8.2 for current release, PHP 8.1 Apache is still tagged as `latest` and PHP 8.2 images are tested using 5.x-dev branch at time of test execution (This will be updated to tagged 5.x release at later date).
15-
16-
- [`8.3-apache-bookworm`, `8.3-apache`, `8.3`, `latest`](https://github.com/brettt89/silverstripe-docker/blob/master/src/8.3/apache/bookworm/Dockerfile)
14+
- [`8.4-apache-bookworm`, `8.4-apache`, `8.4`, `latest`](https://github.com/brettt89/silverstripe-docker/blob/master/src/8.4/apache/bookworm/Dockerfile)
15+
- [`8.4-apache-trixie`](https://github.com/brettt89/silverstripe-docker/blob/master/src/8.4/apache/trixie/Dockerfile)
16+
- [`8.4-fpm-bookworm`, `8.4-fpm`](https://github.com/brettt89/silverstripe-docker/blob/master/src/8.4/fpm/bookworm/Dockerfile)
17+
- [`8.4-fpm-trixie`](https://github.com/brettt89/silverstripe-docker/blob/master/src/8.4/fpm/trixie/Dockerfile)
18+
- [`8.4-fpm-alpine`](https://github.com/brettt89/silverstripe-docker/blob/master/src/8.4/fpm/alpine/Dockerfile)
19+
- [`8.4-cli-bookworm`, `8.4-cli`](https://github.com/brettt89/silverstripe-docker/blob/master/src/8.4/cli/bookworm/Dockerfile)
20+
- [`8.4-cli-trixie`](https://github.com/brettt89/silverstripe-docker/blob/master/src/8.4/cli/trixie/Dockerfile)
21+
- [`8.4-cli-alpine`](https://github.com/brettt89/silverstripe-docker/blob/master/src/8.4/cli/alpine/Dockerfile)
22+
- [`8.3-apache-bookworm`, `8.3-apache`, `8.3`](https://github.com/brettt89/silverstripe-docker/blob/master/src/8.3/apache/bookworm/Dockerfile)
1723
- [`8.3-apache-bullseye`](https://github.com/brettt89/silverstripe-docker/blob/master/src/8.3/apache/bullseye/Dockerfile)
1824
- [`8.3-fpm-bookworm`, `8.3-fpm`](https://github.com/brettt89/silverstripe-docker/blob/master/src/8.3/fpm/bookworm/Dockerfile)
1925
- [`8.3-fpm-bullseye`](https://github.com/brettt89/silverstripe-docker/blob/master/src/8.3/fpm/bullseye/Dockerfile)
@@ -154,7 +160,7 @@ services:
154160
- SS_DEFAULT_ADMIN_PASSWORD=password
155161

156162
database:
157-
image: mysql:5.7
163+
image: mysql:8.1
158164
environment:
159165
- MYSQL_ALLOW_EMPTY_PASSWORD=yes
160166
volumes:

build/build-regex.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ set -euo pipefail
33

44
REGEX="${1:-}"
55

6-
PHP_VERSION_ARRAY=("8.3" "8.2" "8.1")
6+
PHP_VERSION_ARRAY=("8.4" "8.3" "8.2" "8.1")
77
VARIATION_ARRAY=("apache" "fpm" "cli")
8-
DISTRO_ARRAY=("bookworm" "bullseye" "alpine")
8+
DISTRO_ARRAY=("trixie" "bookworm" "bullseye" "alpine")
99

1010
function build() {
1111
local ARG_VERSION=${1:-}
@@ -36,6 +36,10 @@ function loop() {
3636
continue
3737
fi
3838

39+
if [ "$DISTRO" == "trixie" ] && [ "$VERSION" != "8.4" ]; then
40+
continue
41+
fi
42+
3943
build "$VERSION" "$VARIATION" "$DISTRO"
4044
done
4145
done

build/update.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ if [ ${#phpVersions[@]} -eq 0 ]; then
1010
'8.1'
1111
'8.2'
1212
'8.3'
13+
'8.4'
1314
)
1415
fi
1516
phpVersions=( "${phpVersions[@]%/}" )
@@ -22,6 +23,7 @@ declare -A variantDebianDistros=(
2223
[8.1]='bullseye bookworm'
2324
[8.2]='bullseye bookworm'
2425
[8.3]='bullseye bookworm'
26+
[8.4]='bookworm trixie'
2527
)
2628

2729
declare -a variantImplementation=(

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ services:
4141
- ${COMPOSER_HOME:-~/.composer}:/tmp
4242

4343
database:
44-
image: mysql:5.7
44+
image: mysql:8.1
4545
environment:
4646
- MYSQL_ALLOW_EMPTY_PASSWORD=yes
4747
volumes:

docs/DockerREADME.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ services:
6868
- SS_DEFAULT_ADMIN_PASSWORD=password
6969

7070
database:
71-
image: mysql:5.7
71+
image: mysql:8.1
7272
environment:
7373
- MYSQL_ALLOW_EMPTY_PASSWORD=yes
7474
volumes:

src/8.4/apache/bookworm/Dockerfile

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
FROM php:8.4-apache-bookworm
2+
LABEL org.opencontainers.image.description="PHP Extended apache image for Silverstripe applications"
3+
LABEL org.opencontainers.image.authors="Brett Tasker '<brett@silverstripe.com>'"
4+
LABEL org.opencontainers.image.url="https://github.com/brettt89/silverstripe-docker"
5+
LABEL org.opencontainers.image.licenses='MIT'
6+
7+
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/bin/install-php-extensions
8+
9+
# Install default PHP Extensions
10+
RUN install-php-extensions \
11+
bcmath \
12+
mysqli \
13+
pdo \
14+
pdo_mysql \
15+
intl \
16+
ldap \
17+
gd \
18+
soap \
19+
tidy \
20+
xsl \
21+
zip \
22+
exif \
23+
gmp \
24+
opcache
25+
26+
# set recommended PHP.ini settings
27+
# see https://secure.php.net/manual/en/opcache.installation.php
28+
RUN set -eux; \
29+
docker-php-ext-enable opcache; \
30+
{ \
31+
echo 'opcache.memory_consumption=128'; \
32+
echo 'opcache.interned_strings_buffer=8'; \
33+
echo 'opcache.max_accelerated_files=4000'; \
34+
echo 'opcache.revalidate_freq=2'; \
35+
echo 'opcache.fast_shutdown=1'; \
36+
} > "$PHP_INI_DIR/conf.d/opcache-recommended.ini"
37+
38+
# Set error handling
39+
RUN echo 'date.timezone = Pacific/Auckland' > "$PHP_INI_DIR/conf.d/timezone.ini" && \
40+
{ \
41+
echo 'log_errors = On'; \
42+
echo 'error_log = /dev/stderr'; \
43+
} > "$PHP_INI_DIR/conf.d/errors.ini"
44+
45+
46+
# Apache configuration
47+
ENV DOCUMENT_ROOT /var/www/html
48+
RUN { \
49+
echo '<VirtualHost *:80>'; \
50+
echo ' DocumentRoot ${DOCUMENT_ROOT}'; \
51+
echo ' LogLevel warn'; \
52+
echo ' ServerSignature Off'; \
53+
echo ' <Directory ${DOCUMENT_ROOT}>'; \
54+
echo ' Options +FollowSymLinks'; \
55+
echo ' Options -ExecCGI -Includes -Indexes'; \
56+
echo ' AllowOverride all'; \
57+
echo; \
58+
echo ' Require all granted'; \
59+
echo ' </Directory>'; \
60+
echo ' <LocationMatch assets/>'; \
61+
echo ' php_flag engine off'; \
62+
echo ' </LocationMatch>'; \
63+
echo; \
64+
echo ' IncludeOptional sites-available/000-default.local*'; \
65+
echo '</VirtualHost>'; \
66+
} > /etc/apache2/sites-available/000-default.conf && \
67+
echo "ServerName localhost" > /etc/apache2/conf-available/fqdn.conf && \
68+
a2enmod rewrite expires remoteip headers

0 commit comments

Comments
 (0)