Skip to content
Open
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
2dfc2a8
Add FrankenPHP build
Prometee Mar 29, 2025
28f1259
Set local credentials
Prometee Mar 29, 2025
ff7a52c
Add composer
matyo91 Mar 29, 2025
5aaaa94
Remove config preload
matyo91 Mar 29, 2025
9efafe2
Remove 8.0 and 8.1
matyo91 Mar 29, 2025
3839cee
Set local credentials
Prometee Mar 29, 2025
7969d7b
Update frankenphp workflow
matyo91 Mar 29, 2025
a765f19
test push image
matyo91 Mar 29, 2025
e1c057c
Add extensions
matyo91 Mar 29, 2025
951b4bb
Dynamic packages
matyo91 Mar 29, 2025
b930686
cleanup space
matyo91 Mar 30, 2025
2549604
Rollback workflow dispatch
matyo91 Mar 30, 2025
e1c1ab7
Update mercure data path
matyo91 Mar 30, 2025
afa549d
Running as a Non-Root User
matyo91 Mar 30, 2025
4ab004d
Rollback folders and non root user permissions
matyo91 Mar 30, 2025
d6a6604
Move backup php ini
matyo91 Mar 30, 2025
23dea53
Update mercure transport url data path
matyo91 Mar 30, 2025
2c62aea
Resolve certificate installation
matyo91 Mar 30, 2025
7fa0e82
Update workflow to build only alpine images and use local credentials…
Prometee Mar 30, 2025
4a99765
Narrow down the tests
Prometee Mar 30, 2025
e84d68e
Remove not required yet fixuid image
Prometee Mar 30, 2025
607753b
Copy from PHP image the used exts
Prometee Mar 30, 2025
ff9e19a
Refactor xdebug build/image
Prometee Mar 30, 2025
8a087fd
Simplify build like FrankenPHP doc is telling us to do it
Prometee Mar 30, 2025
3440d8f
Remove opcache preload since no source are available yet
Prometee Mar 30, 2025
4df3097
Merge remote-tracking branch 'Prometee/frankenphp' into frankenphp
matyo91 Mar 30, 2025
cbd1fab
Refactor build
matyo91 Mar 30, 2025
a3b35f6
Update platform specific deps
matyo91 Mar 30, 2025
48e9fc6
Fix action cache version
matyo91 Mar 30, 2025
49ce144
force build image
matyo91 Mar 30, 2025
454757d
Rollback force build image
matyo91 Mar 30, 2025
9cb9149
fix docker login
matyo91 Mar 30, 2025
b7d6b48
disable bazel for build
matyo91 Mar 30, 2025
4f58b48
No PWA
matyo91 Mar 30, 2025
ead9fce
Change root directory
matyo91 Mar 30, 2025
39ea03f
Remove no more required file and clean configurations
Prometee Apr 1, 2025
eb5e7c9
Remove fpm for Bazel tests
Prometee Apr 2, 2025
84e3161
Remove not required Caddyfile
Prometee Apr 3, 2025
b82d5e3
Add dev target to build XDebug image
Prometee Apr 3, 2025
d0ceec8
Fix image tag name
Prometee Apr 7, 2025
fedeaae
Use secrets and repository var
Prometee Apr 7, 2025
76cfaa3
Remove comments
Prometee Apr 7, 2025
df61659
Remove new lines
Prometee Apr 7, 2025
e19ae5d
Remove new lines
Prometee Apr 7, 2025
d2f715c
Merge branch 'main' into frankenphp
Rafikooo Jun 12, 2026
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
241 changes: 241 additions & 0 deletions .github/workflows/sylius-frankenphp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,241 @@
name: FrankenPHP Docker Image CI for Sylius

on:
workflow_dispatch: ~
push:
branches: [ main, frankenphp ]
paths:
- 'frankenphp/**'
- 'WORKSPACE'
schedule:
- cron: '0 20 * * 5'

concurrency:
group: sylius_frankenphp_build
cancel-in-progress: false

jobs:

build:

name: "Sylius FrankenPHP - ${{ matrix.frankenphp }}${{ matrix.php }} ${{ matrix.distro }}"
Comment thread
Prometee marked this conversation as resolved.

runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
frankenphp: [ "1.5-php" ]
php: [ "8.2", "8.3", "8.4" ]
distro: [ "alpine" ]

steps:

- uses: actions/checkout@v4
Comment thread
Prometee marked this conversation as resolved.

- name: Generate UUID
id: generate-uuid
run: |
UUID=$(cat /proc/sys/kernel/random/uuid)
echo "UUID=${UUID}" >> $GITHUB_OUTPUT

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ vars.DOCKER_FRANKENPHP_REPOSITORY_NAME }}
tags: |
type=raw,value=${{ matrix.frankenphp }}${{ matrix.php }}-${{ matrix.distro }}
labels: |
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
org.opencontainers.image.description=Sylius FrankenPHP ${{ matrix.frankenphp }}${{ matrix.php }} Docker image
org.opencontainers.image.licenses=MIT

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: "${{ runner.os }}-frankenphp-${{ matrix.frankenphp }}${{ matrix.php }}-${{ matrix.distro }}-buildx-cache-${{ vars.CACHE_VERSION }}-${{ steps.generate-uuid.outputs.uuid }}"
# https://github.com/actions/cache/issues/109#issuecomment-558771281
# https://github.community/t/always-save-new-cache-for-incremental-builds/172791
restore-keys: "${{ runner.os }}-frankenphp-${{ matrix.frankenphp }}${{ matrix.php }}-${{ matrix.distro }}-buildx-cache-${{ vars.CACHE_VERSION }}-"

- name: Docker Login
uses: docker/login-action@v3
with:
registry: ${{ secrets.DOCKER_REGISTRY }}
username: ${{ secrets.DOCKER_REPOSITORY_LOGIN }}
password: ${{ secrets.DOCKER_REPOSITORY_PASSWORD }}
logout: true

- name: Build multiplatform
uses: docker/build-push-action@v5
with:
file: ./frankenphp/Dockerfile
context: ./frankenphp
build-args: "FRANKENPHP_VERSION=${{ matrix.frankenphp }}${{ matrix.php }}-${{ matrix.distro }}"
platforms: linux/amd64,linux/arm64
push: false
pull: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new

- name: Build linux/amd64 to tar
uses: docker/build-push-action@v5
with:
file: ./frankenphp/Dockerfile
context: ./frankenphp
build-args: "FRANKENPHP_VERSION=${{ matrix.frankenphp }}${{ matrix.php }}-${{ matrix.distro }}"
platforms: linux/amd64
push: false
pull: false
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=local,src=/tmp/.buildx-cache-new
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new-amd64
outputs: type=docker,dest=./external/image-amd64.tar

- name: Build linux/arm64 to tar
uses: docker/build-push-action@v5
with:
file: ./frankenphp/Dockerfile
context: ./frankenphp
build-args: "FRANKENPHP_VERSION=${{ matrix.frankenphp }}${{ matrix.php }}-${{ matrix.distro }}"
platforms: linux/arm64
push: false
pull: false
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=local,src=/tmp/.buildx-cache-new
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new-arm64
outputs: type=docker,dest=./external/image-arm64.tar

- name: Mount Bazel cache
uses: actions/cache@v4
with:
path: "~/.cache/bazel"
key: "${{ runner.os }}-frankenphp-${{ matrix.frankenphp }}${{ matrix.php }}-${{ matrix.distro }}-bazel-cache-${{ vars.CACHE_VERSION }}-${{ steps.generate-uuid.outputs.uuid }}"
restore-keys: "${{ runner.os }}-frankenphp-${{ matrix.frankenphp }}${{ matrix.php }}-${{ matrix.distro }}-bazel-cache-${{ vars.CACHE_VERSION }}-"

- name: Setup PHP for Bazel
run: |
set -ex
cat > frankenphp/php-version.bzl <<EOF
PHP_VERSION = "${{ matrix.php }}"
EOF
cat > frankenphp/frankenphp-arch.bzl <<EOF
ARCHITECTURES = ["amd64", "arm64"]
EOF

- name: Bazel build and test
run: |
set -ex
targets=$(bazel query 'attr(visibility, "//visibility:public", //frankenphp:*)' | sort)
bazel build --curses=no ${targets}
bazel test --curses=no --test_output=errors ${targets}

- name: Push
uses: docker/build-push-action@v5
with:
file: ./frankenphp/Dockerfile
context: ./frankenphp
build-args: "FRANKENPHP_VERSION=${{ matrix.frankenphp }}${{ matrix.php }}-${{ matrix.distro }}"
platforms: linux/amd64,linux/arm64
push: ${{ github.ref == 'refs/heads/frankenphp' || github.ref == 'refs/heads/main' || github.event_name == 'release' }}
pull: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache-new
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new

- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache

build-xdebug:
needs: build

name: "Sylius FrankenPHP with Xdebug - ${{ matrix.frankenphp }}${{ matrix.php }}-${{ matrix.distro }}"

runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
frankenphp: [ "1.5-php" ]
php: [ "8.2", "8.3", "8.4" ]
distro: [ "alpine" ]

steps:

- uses: actions/checkout@v4

- name: Generate UUID
id: generate-uuid
run: |
UUID=$(cat /proc/sys/kernel/random/uuid)
echo "UUID=${UUID}" >> $GITHUB_OUTPUT

- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v3

- name: Available platforms
run: echo ${{ steps.qemu.outputs.platforms }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ vars.DOCKER_FRANKENPHP_REPOSITORY_NAME }}
tags: |
type=raw,value=${{ matrix.frankenphp }}${{ matrix.php }}-xdebug-${{ matrix.distro }}
labels: |
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
org.opencontainers.image.description=Sylius FrankenPHP with XDebug ${{ matrix.frankenphp }}${{ matrix.php }} Docker image
org.opencontainers.image.licenses=MIT

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: "${{ runner.os }}-frankenphp-${{ matrix.frankenphp }}${{ matrix.php }}-xdebug-${{ matrix.distro }}-buildx-cache-${{ vars.CACHE_VERSION }}-${{ steps.generate-uuid.outputs.uuid }}"
# https://github.com/actions/cache/issues/109#issuecomment-558771281
# https://github.community/t/always-save-new-cache-for-incremental-builds/172791
restore-keys: "${{ runner.os }}-frankenphp-${{ matrix.frankenphp }}${{ matrix.php }}-xdebug-${{ matrix.distro }}-buildx-cache-${{ vars.CACHE_VERSION }}-"

- name: Docker Login
uses: docker/login-action@v3
with:
registry: ${{ secrets.DOCKER_REGISTRY }}
username: ${{ secrets.DOCKER_REPOSITORY_LOGIN }}
password: ${{ secrets.DOCKER_REPOSITORY_PASSWORD }}
logout: true

- name: Build and push
uses: docker/build-push-action@v5.0.0
with:
file: ./frankenphp/Dockerfile
context: ./frankenphp
build-args: "FRANKENPHP_VERSION=${{ matrix.frankenphp }}${{ matrix.php }}-${{ matrix.distro }}"
platforms: linux/amd64,linux/arm64
push: ${{ github.ref == 'refs/heads/frankenphp' || github.ref == 'refs/heads/main' || github.event_name == 'release' }}
pull: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new
target: "frankenphp_dev"

- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
16 changes: 16 additions & 0 deletions frankenphp/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
load("@io_bazel_rules_docker//container:import.bzl", "container_import")
load("@io_bazel_rules_docker//contrib:test.bzl", "container_test")
load(":frankenphp-arch.bzl", "ARCHITECTURES")
load(":php-version.bzl", "PHP_VERSION")

package(default_visibility = ["//visibility:public"])

[
container_test(
name = "frankenphp-php" + PHP_VERSION + "_" + arch + "_test",
size = "medium",
configs = ["testdata/frankenphp-php" + PHP_VERSION + "_" + arch + ".yaml"],
image = "@image" + arch + "//image",
)
for arch in ARCHITECTURES
]
65 changes: 65 additions & 0 deletions frankenphp/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#syntax=docker/dockerfile:1
ARG FRANKENPHP_VERSION=1.5-php8.2-alpine

# Adapted from https://github.com/dunglas/symfony-docker

# Versions
FROM dunglas/frankenphp:${FRANKENPHP_VERSION} AS frankenphp_upstream

# The different stages of this Dockerfile are meant to be built into separate images
# https://docs.docker.com/develop/develop-images/multistage-build/#stop-at-a-specific-build-stage
# https://docs.docker.com/compose/compose-file/#target
Comment thread
Prometee marked this conversation as resolved.
Outdated

# Base FrankenPHP image
FROM frankenphp_upstream AS frankenphp_base

WORKDIR /srv/sylius

# https://getcomposer.org/doc/03-cli.md#composer-allow-superuser
ENV COMPOSER_ALLOW_SUPERUSER=1

# persistent / runtime deps
# hadolint ignore=DL3008
RUN install-php-extensions \
@composer \
apcu \
exif \
gd \
intl \
pdo_mysql \
opcache \
zip

COPY --link conf.d/app.ini $PHP_INI_DIR/conf.d/
COPY --link conf.d/app-cli.ini $PHP_INI_DIR/conf.d/

HEALTHCHECK --start-period=60s CMD curl -f http://localhost:2019/metrics || exit 1
CMD [ "frankenphp", "run", "--config", "/etc/caddy/Caddyfile" ]

# Dev FrankenPHP image
FROM frankenphp_base AS frankenphp_dev

ENV APP_ENV=dev XDEBUG_MODE=off
VOLUME /app/var/

RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"

RUN set -eux; \
install-php-extensions \
xdebug \
;

COPY --link conf.d/app.dev.ini $PHP_INI_DIR/conf.d/

CMD [ "frankenphp", "run", "--config", "/etc/caddy/Caddyfile", "--watch" ]

# Prod FrankenPHP image
FROM frankenphp_base AS frankenphp_prod

ENV APP_ENV=prod
ENV FRANKENPHP_CONFIG="import worker.Caddyfile"

RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"

COPY --link conf.d/app.prod.ini $PHP_INI_DIR/conf.d/
COPY --link worker.Caddyfile /etc/caddy/worker.Caddyfile
16 changes: 16 additions & 0 deletions frankenphp/conf.d/app-cli.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apc.enable_cli = 1
date.timezone = ${PHP_DATE_TIMEZONE}
opcache.enable_cli = 1
session.auto_start = Off
short_open_tag = Off

# http://symfony.com/doc/current/performance.html
opcache.interned_strings_buffer = 16
opcache.max_accelerated_files = 20000
opcache.memory_consumption = 256
realpath_cache_size = 4096K
realpath_cache_ttl = 600

memory_limit = 3G
post_max_size = 6M
upload_max_filesize = 5M
5 changes: 5 additions & 0 deletions frankenphp/conf.d/app.dev.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
; See https://docs.docker.com/desktop/networking/#i-want-to-connect-from-a-container-to-a-service-on-the-host
; See https://github.com/docker/for-linux/issues/264
; The `client_host` below may optionally be replaced with `discover_client_host=yes`
; Add `start_with_request=yes` to start debug session on each request
xdebug.client_host = xdebug://gateway
15 changes: 15 additions & 0 deletions frankenphp/conf.d/app.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apc.enable_cli = 1
date.timezone = ${PHP_DATE_TIMEZONE}
opcache.enable_cli = 1
session.auto_start = Off
short_open_tag = Off

# http://symfony.com/doc/current/performance.html
opcache.interned_strings_buffer = 16
opcache.max_accelerated_files = 20000
opcache.memory_consumption = 256
realpath_cache_size = 4096K
realpath_cache_ttl = 600

post_max_size = 6M
upload_max_filesize = 5M
1 change: 1 addition & 0 deletions frankenphp/conf.d/app.prod.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
opcache.preload_user = root
Loading