Skip to content

Commit d9aa877

Browse files
authored
Merge pull request #128 from shopware/feat/frankenphp
feat: add frankenphp variant
2 parents 5f3707e + 53edb13 commit d9aa877

7 files changed

Lines changed: 345 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,138 @@ jobs:
3939
echo "$MATRIX" >> $GITHUB_OUTPUT
4040
echo 'EOF' >> $GITHUB_OUTPUT
4141
42+
frankenphp-amd64:
43+
name: FrankenPHP (amd64)
44+
runs-on: ubuntu-24.04
45+
46+
needs: [generate-matrix]
47+
strategy: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
48+
steps:
49+
- name: Checkout
50+
uses: actions/checkout@v4
51+
52+
- name: Set up Docker Buildx
53+
uses: docker/setup-buildx-action@v3
54+
55+
- name: Login into Docker Hub
56+
if: github.ref == 'refs/heads/main'
57+
run: echo "${{ secrets.DOCKER_HUB_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
58+
59+
- name: Login into Github Docker Registery
60+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
61+
62+
- name: Build and Push
63+
if: matrix.php != '8.1'
64+
uses: docker/build-push-action@v6
65+
with:
66+
tags: |
67+
${{ matrix.frankenphp-tags-amd64 }}
68+
context: frankenphp
69+
cache-from: type=gha,scope=frankenphp-${{ matrix.php }}-amd64
70+
cache-to: type=gha,mode=max,scope=frankenphp-${{ matrix.php }}-amd64
71+
platforms: linux/amd64
72+
build-args: |
73+
PHP_VERSION=${{ matrix.php }}
74+
PHP_PATCH_VERSION=${{ matrix.phpPatch }}
75+
PHP_DIGEST=${{ matrix.phpPatchDigest }}
76+
REDIS_PHP_MODULE=${{ matrix.redisPHPModule }}
77+
push: true
78+
provenance: false
79+
80+
frankenphp-arm64:
81+
name: FrankenPHP (arm64)
82+
runs-on: ubuntu-24.04-arm
83+
84+
needs: [generate-matrix]
85+
strategy: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
86+
steps:
87+
- name: Checkout
88+
uses: actions/checkout@v4
89+
90+
- name: Set up Docker Buildx
91+
uses: docker/setup-buildx-action@v3
92+
93+
- name: Login into Docker Hub
94+
if: github.ref == 'refs/heads/main'
95+
run: echo "${{ secrets.DOCKER_HUB_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
96+
97+
- name: Login into Github Docker Registery
98+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
99+
100+
- name: Build and Push
101+
if: matrix.php != '8.1'
102+
uses: docker/build-push-action@v6
103+
with:
104+
tags: |
105+
${{ matrix.frankenphp-tags-arm64 }}
106+
context: frankenphp
107+
cache-from: type=gha,scope=frankenphp-${{ matrix.php }}-arm64
108+
cache-to: type=gha,mode=max,scope=frankenphp-${{ matrix.php }}-arm64
109+
platforms: linux/arm64
110+
build-args: |
111+
PHP_VERSION=${{ matrix.php }}
112+
PHP_PATCH_VERSION=${{ matrix.phpPatch }}
113+
PHP_DIGEST=${{ matrix.phpPatchDigest }}
114+
REDIS_PHP_MODULE=${{ matrix.redisPHPModule }}
115+
push: true
116+
provenance: false
117+
118+
frankenphp:
119+
name: FrankenPHP merge manifest
120+
runs-on: ubuntu-24.04
121+
122+
strategy: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
123+
needs: [generate-matrix, frankenphp-amd64, frankenphp-arm64]
124+
steps:
125+
- name: Login into Docker Hub
126+
if: github.ref == 'refs/heads/main'
127+
run: echo "${{ secrets.DOCKER_HUB_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
128+
129+
- name: Login into Github Docker Registery
130+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
131+
132+
- name: Merge manifest
133+
if: matrix.php != '8.1'
134+
run: |
135+
${{ matrix.frankenphp-merge }}
136+
137+
frankenphp-otel:
138+
name: FrankenPHP OTEL
139+
runs-on: ubuntu-24.04
140+
needs: [generate-matrix, frankenphp]
141+
strategy: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
142+
steps:
143+
- name: Checkout
144+
uses: actions/checkout@v4
145+
146+
- name: Set up Docker Buildx
147+
uses: docker/setup-buildx-action@v3
148+
149+
- name: Set up QEMU
150+
uses: docker/setup-qemu-action@v3
151+
152+
- name: Login into Docker Hub
153+
if: github.ref == 'refs/heads/main'
154+
run: echo "${{ secrets.DOCKER_HUB_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
155+
156+
- name: Login into Github Docker Registery
157+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
158+
159+
- name: Build and Push
160+
if: matrix.php != '8.1'
161+
uses: docker/build-push-action@v6
162+
with:
163+
tags: |
164+
${{ matrix.frankenphp-tags-otel }}
165+
context: frankenphp-otel
166+
platforms: linux/amd64,linux/arm64
167+
cache-from: type=gha,scope=frankenphp-otel-${{ matrix.php }}
168+
cache-to: type=gha,mode=max,scope=frankenphp-otel-${{ matrix.php }}
169+
build-args: |
170+
FRANKENPHP_IMAGE=${{ matrix.frankenphp-image }}
171+
push: true
172+
provenance: false
173+
42174
fpm-amd64:
43175
name: PHP FPM ${{ matrix.php }} (amd64)
44176
runs-on: ubuntu-24.04

frankenphp-otel/Dockerfile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#syntax=docker/dockerfile:1.4
2+
3+
ARG FRANKENPHP_IMAGE=ghcr.io/shopware/docker-base-ci-test:15628943495-8.4-frankenphp
4+
5+
FROM ${FRANKENPHP_IMAGE}
6+
7+
USER root
8+
9+
RUN <<EOF
10+
set -e
11+
apt-get update
12+
apt-get install -y libgrpc++1.51 libgrpc-dev git
13+
GRPC_VERSION=$(dpkg -s libgrpc-dev | grep '^Version:' | cut -d' ' -f2 | cut -d'-' -f1)
14+
git clone --depth 1 -b v${GRPC_VERSION} https://github.com/grpc/grpc /tmp/grpc
15+
cd /tmp/grpc/src/php/ext/grpc
16+
phpize
17+
./configure
18+
make
19+
make install
20+
cd /root
21+
rm -rf /tmp/grpc
22+
apt-get remove -y git libgrpc-dev
23+
apt-get autoremove -y
24+
install-php-extensions opentelemetry
25+
rm -rf /var/cache/apt/archives /var/lib/apt/lists/*
26+
echo "extension=grpc.so" > /usr/local/etc/php/conf.d/grpc.ini
27+
EOF
28+
29+
USER www-data

frankenphp/Dockerfile

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#syntax=docker/dockerfile:1.4
2+
#check=skip=SecretsUsedInArgOrEnv
3+
ARG PHP_VERSION=8.4
4+
FROM dunglas/frankenphp:builder-php${PHP_VERSION} AS builder
5+
COPY --from=caddy:builder /usr/bin/xcaddy /usr/bin/xcaddy
6+
7+
RUN CGO_ENABLED=1 \
8+
XCADDY_SETCAP=1 \
9+
XCADDY_GO_BUILD_FLAGS="-ldflags='-w -s' -tags=nobadger,nomysql,nopgx" \
10+
CGO_CFLAGS=$(php-config --includes) \
11+
CGO_LDFLAGS="$(php-config --ldflags) $(php-config --libs)" \
12+
xcaddy build \
13+
--output /usr/local/bin/frankenphp \
14+
--with github.com/dunglas/frankenphp=./ \
15+
--with github.com/dunglas/frankenphp/caddy=./caddy/ \
16+
--with github.com/dunglas/caddy-cbrotli \
17+
--with github.com/dunglas/mercure/caddy \
18+
--with github.com/dunglas/vulcain/caddy \
19+
--with github.com/lolPants/caddy-requestid
20+
21+
ARG PHP_VERSION=8.4
22+
FROM dunglas/frankenphp:php${PHP_VERSION}
23+
24+
RUN <<EOF
25+
set -e
26+
apt-get update
27+
apt-get upgrade -y
28+
install-php-extensions bcmath gd intl mysqli pdo_mysql pcntl sockets bz2 gmp soap zip ffi opcache redis apcu amqp zstd
29+
mkdir -p /var/www/html
30+
chown -R www-data:www-data /data/caddy && chown -R www-data:www-data /config/caddy
31+
rm -rf /var/cache/apt/archives /var/lib/apt/lists/*
32+
EOF
33+
34+
ENV APP_ENV=prod \
35+
APP_URL_CHECK_DISABLED=1 \
36+
LOCK_DSN=flock \
37+
MAILER_DSN=null://localhost \
38+
DATABASE_PORT=3306 \
39+
OPENSEARCH_URL= \
40+
BLUE_GREEN_DEPLOYMENT=0 \
41+
SHOPWARE_ES_ENABLED=0 \
42+
SHOPWARE_ES_INDEXING_ENABLED=0 \
43+
SHOPWARE_ES_INDEX_PREFIX= \
44+
SHOPWARE_HTTP_CACHE_ENABLED=1 \
45+
SHOPWARE_HTTP_DEFAULT_TTL=7200 \
46+
SHOPWARE_CACHE_ID=docker \
47+
SHOPWARE_SKIP_WEBINSTALLER=1 \
48+
COMPOSER_HOME=/tmp/composer \
49+
COMPOSER_ROOT_VERSION=1.0.0 \
50+
INSTALL_LOCALE=en-GB \
51+
INSTALL_CURRENCY=EUR \
52+
INSTALL_ADMIN_USERNAME=admin \
53+
INSTALL_ADMIN_PASSWORD=shopware \
54+
PHP_SESSION_COOKIE_LIFETIME=0 \
55+
PHP_SESSION_GC_MAXLIFETIME=1440 \
56+
PHP_SESSION_HANDLER=files \
57+
PHP_SESSION_SAVE_PATH= \
58+
PHP_MAX_UPLOAD_SIZE=128m \
59+
PHP_MAX_EXECUTION_TIME=300 \
60+
PHP_MEMORY_LIMIT=512m \
61+
PHP_DISPLAY_ERRORS=Off \
62+
PHP_ERROR_REPORTING=E_ALL \
63+
PHP_OPCACHE_ENABLE_CLI=0 \
64+
PHP_OPCACHE_VALIDATE_TIMESTAMPS=0 \
65+
PHP_OPCACHE_INTERNED_STRINGS_BUFFER=20 \
66+
PHP_OPCACHE_MAX_ACCELERATED_FILES=10000 \
67+
PHP_OPCACHE_MEMORY_CONSUMPTION=128 \
68+
PHP_OPCACHE_FILE_CACHE= \
69+
PHP_OPCACHE_FILE_CACHE_ONLY=0 \
70+
PHP_OPCACHE_FILE_OVERRIDE=1 \
71+
PHP_REALPATH_CACHE_SIZE=4096K \
72+
PHP_REALPATH_CACHE_TTL=3600
73+
74+
USER www-data
75+
76+
COPY --link rootfs /
77+
COPY --from=builder --link /usr/local/bin/frankenphp /usr/local/bin/frankenphp
78+
79+
WORKDIR /var/www/html
80+
81+
EXPOSE 8000
82+
83+
CMD ["--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"]
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
skip_install_trust
3+
4+
{$CADDY_GLOBAL_OPTIONS}
5+
{$CADDY_EXTRA_CONFIG}
6+
7+
frankenphp {
8+
{$FRANKENPHP_CONFIG}
9+
}
10+
}
11+
12+
:8000 {
13+
encode gzip zstd
14+
php_server {
15+
root /var/www/html
16+
resolve_root_symlink false
17+
}
18+
19+
{$CADDY_SERVER_EXTRA_DIRECTIVES}
20+
}

frankenphp/rootfs/setup

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env sh
2+
3+
set -e
4+
5+
cd /var/www/html
6+
7+
if [[ -e /var/www/html/vendor/bin/shopware-deployment-helper ]]; then
8+
exec ./vendor/bin/shopware-deployment-helper run
9+
fi
10+
11+
echo "### ERROR ###"
12+
echo ""
13+
echo "### The setup scripts are removed ###"
14+
echo "### Please install the Shopware Deployment Helper using composer require shopware/deployment-helper to continue ###"
15+
echo "### For more information see https://developer.shopware.com/docs/guides/hosting/installation-updates/deployments/deployment-helper.html ###"
16+
echo ""
17+
echo "### ERROR ###"
18+
echo ""
19+
20+
exit 1
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
expose_php = Off
2+
error_reporting = ${PHP_ERROR_REPORTING}
3+
display_errors = ${PHP_DISPLAY_ERRORS}
4+
display_startup_errors = ${PHP_DISPLAY_ERRORS}
5+
6+
upload_max_filesize = ${PHP_MAX_UPLOAD_SIZE}
7+
post_max_size = ${PHP_MAX_UPLOAD_SIZE}
8+
max_execution_time = ${PHP_MAX_EXECUTION_TIME}
9+
memory_limit = ${PHP_MEMORY_LIMIT}
10+
11+
session.cookie_lifetime = ${PHP_SESSION_COOKIE_LIFETIME}
12+
session.save_handler = ${PHP_SESSION_HANDLER}
13+
session.save_path = ${PHP_SESSION_SAVE_PATH}
14+
session.gc_probability = 0
15+
session.gc_maxlifetime = ${PHP_SESSION_GC_MAXLIFETIME}
16+
17+
opcache.enable_cli = ${PHP_OPCACHE_ENABLE_CLI}
18+
opcache.enable_file_override = ${PHP_OPCACHE_FILE_OVERRIDE}
19+
opcache.validate_timestamps = ${PHP_OPCACHE_VALIDATE_TIMESTAMPS}
20+
opcache.interned_strings_buffer = ${PHP_OPCACHE_INTERNED_STRINGS_BUFFER}
21+
opcache.max_accelerated_files= ${PHP_OPCACHE_MAX_ACCELERATED_FILES}
22+
opcache.memory_consumption = ${PHP_OPCACHE_MEMORY_CONSUMPTION}
23+
opcache.file_cache = ${PHP_OPCACHE_FILE_CACHE}
24+
opcache.file_cache_only = ${PHP_OPCACHE_FILE_CACHE_ONLY}
25+
26+
zend.assertions = -1
27+
zend.detect_unicode = 0
28+
29+
realpath_cache_ttl = ${PHP_REALPATH_CACHE_TTL}
30+
realpath_cache_size = ${PHP_REALPATH_CACHE_SIZE}

matrix.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,16 @@ function get_digest_of_image(string $imageName, string $tag): string {
100100
'ghcr.io/shopware/docker-base' . $imageSuffix . ':' . $imageTagPrefix . $patchVersion['version'] . '-nginx-otel',
101101
];
102102

103+
$frankenphpImages = [
104+
'ghcr.io/shopware/docker-base' . $imageSuffix . ':' . $imageTagPrefix . $supportedVersion . '-frankenphp',
105+
'ghcr.io/shopware/docker-base' . $imageSuffix . ':' . $imageTagPrefix . $patchVersion['version'] . '-frankenphp'
106+
];
107+
108+
$frankenphpImagesOtel = [
109+
'ghcr.io/shopware/docker-base' . $imageSuffix . ':' . $imageTagPrefix . $supportedVersion . '-frankenphp-otel',
110+
'ghcr.io/shopware/docker-base' . $imageSuffix . ':' . $imageTagPrefix . $patchVersion['version'] . '-frankenphp-otel'
111+
];
112+
103113
$fpmImages = [
104114
'ghcr.io/shopware/docker-base' . $imageSuffix . ':' . $imageTagPrefix . $supportedVersion . '-fpm',
105115
'ghcr.io/shopware/docker-base' . $imageSuffix . ':' . $imageTagPrefix . $patchVersion['version'] . '-fpm'
@@ -142,6 +152,16 @@ function get_digest_of_image(string $imageName, string $tag): string {
142152
'shopware/docker-base:' . $imageTagPrefix . $supportedVersion . '-fpm-otel',
143153
'shopware/docker-base:' . $imageTagPrefix . $patchVersion['version'] . '-fpm-otel'
144154
]);
155+
156+
$frankenphpImages = array_merge($frankenphpImages, [
157+
'shopware/docker-base:' . $imageTagPrefix . $supportedVersion . '-frankenphp',
158+
'shopware/docker-base:' . $imageTagPrefix . $patchVersion['version'] . '-frankenphp'
159+
]);
160+
161+
$frankenphpImagesOtel = array_merge($frankenphpImagesOtel, [
162+
'shopware/docker-base:' . $imageTagPrefix . $supportedVersion . '-frankenphp-otel',
163+
'shopware/docker-base:' . $imageTagPrefix . $patchVersion['version'] . '-frankenphp-otel'
164+
]);
145165
}
146166

147167
$redisModule = 'redis';
@@ -156,10 +176,21 @@ function get_digest_of_image(string $imageName, string $tag): string {
156176
$manifestMergeScript .= 'docker manifest push ' . $fpmImage . "\n";
157177
}
158178

179+
$manifestMergeScriptFrankenphp = '';
180+
foreach($frankenphpImages as $frankenphpImage) {
181+
$manifestMergeScriptFrankenphp .= 'docker manifest create ' . $frankenphpImage . ' ' . $frankenphpImage . '-amd64 ' . $frankenphpImage . '-arm64' . "\n";
182+
$manifestMergeScriptFrankenphp .= 'docker manifest push ' . $frankenphpImage . "\n";
183+
}
184+
159185
$data[] = [
160186
'php' => $supportedVersion,
161187
'phpPatch' => $patchVersion['version'],
162188
'phpPatchDigest' => $phpDigest,
189+
'frankenphp-image' => 'ghcr.io/shopware/docker-base' . $imageSuffix . ':' . $imageTagPrefix . $supportedVersion . '-frankenphp',
190+
'frankenphp-merge' => $manifestMergeScriptFrankenphp,
191+
'frankenphp-tags-amd64' => implode("\n", array_map(fn($tag) => $tag . '-amd64', $frankenphpImages)),
192+
'frankenphp-tags-arm64' => implode("\n", array_map(fn($tag) => $tag . '-arm64', $frankenphpImages)),
193+
'frankenphp-tags-otel' => implode("\n", $frankenphpImagesOtel),
163194
'fpm-image' => 'ghcr.io/shopware/docker-base' . $imageSuffix . ':' . $imageTagPrefix . $supportedVersion . '-fpm',
164195
'fpm-tags' => implode("\n", $fpmImages),
165196
'fpm-merge' => $manifestMergeScript,

0 commit comments

Comments
 (0)