-
-
Notifications
You must be signed in to change notification settings - Fork 10
[Sylius Hackathon - Paris Mars 2025] Add FrankenPHP build #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Prometee
wants to merge
45
commits into
Sylius:main
Choose a base branch
from
Prometee:frankenphp
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 41 commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
2dfc2a8
Add FrankenPHP build
Prometee 28f1259
Set local credentials
Prometee ff7a52c
Add composer
matyo91 5aaaa94
Remove config preload
matyo91 9efafe2
Remove 8.0 and 8.1
matyo91 3839cee
Set local credentials
Prometee 7969d7b
Update frankenphp workflow
matyo91 a765f19
test push image
matyo91 e1c057c
Add extensions
matyo91 951b4bb
Dynamic packages
matyo91 b930686
cleanup space
matyo91 2549604
Rollback workflow dispatch
matyo91 e1c1ab7
Update mercure data path
matyo91 afa549d
Running as a Non-Root User
matyo91 4ab004d
Rollback folders and non root user permissions
matyo91 d6a6604
Move backup php ini
matyo91 23dea53
Update mercure transport url data path
matyo91 2c62aea
Resolve certificate installation
matyo91 7fa0e82
Update workflow to build only alpine images and use local credentials…
Prometee 4a99765
Narrow down the tests
Prometee e84d68e
Remove not required yet fixuid image
Prometee 607753b
Copy from PHP image the used exts
Prometee ff9e19a
Refactor xdebug build/image
Prometee 8a087fd
Simplify build like FrankenPHP doc is telling us to do it
Prometee 3440d8f
Remove opcache preload since no source are available yet
Prometee 4df3097
Merge remote-tracking branch 'Prometee/frankenphp' into frankenphp
matyo91 cbd1fab
Refactor build
matyo91 a3b35f6
Update platform specific deps
matyo91 48e9fc6
Fix action cache version
matyo91 49ce144
force build image
matyo91 454757d
Rollback force build image
matyo91 9cb9149
fix docker login
matyo91 b7d6b48
disable bazel for build
matyo91 4f58b48
No PWA
matyo91 ead9fce
Change root directory
matyo91 39ea03f
Remove no more required file and clean configurations
Prometee eb5e7c9
Remove fpm for Bazel tests
Prometee 84e3161
Remove not required Caddyfile
Prometee b82d5e3
Add dev target to build XDebug image
Prometee d0ceec8
Fix image tag name
Prometee fedeaae
Use secrets and repository var
Prometee 76cfaa3
Remove comments
Prometee df61659
Remove new lines
Prometee e19ae5d
Remove new lines
Prometee d2f715c
Merge branch 'main' into frankenphp
Rafikooo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }}" | ||
|
|
||
| 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 | ||
|
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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
|
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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| opcache.preload_user = root |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.