-
-
Notifications
You must be signed in to change notification settings - Fork 172
Release 4.0: Add FrankenPHP & more Laravel optmizations #283
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
Conversation
|
This would be super cool to have! Great work on this so far! |
Deploying serversideup-php with
|
| Latest commit: |
f7cd1d7
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://e2aee8a9.serversideup-php.pages.dev |
| Branch Preview URL: | https://280-create-a-frankenphp-vari.serversideup-php.pages.dev |
|
This would really be a nice addition.. |
|
This will be a wonderful addition! |
|
This would be a great feature! 🚀 |
|
Not sure how I missed your message @mihai-burduselu-ptt. I am getting v3.4 updates out the door for the last major optimizations for |
|
This is a great addition to serversideup. Any updates regarding frankenPHP? |
|
I'd like to see FrankenPHP added too. |
|
Thanks for your patience, all! I'm looking for the future of PHP and I really hope FrankenPHP is it. I've been very busy with Spin and once I get this big release of Spin v3 out the door, then I will be swinging to this. Exploring FrankenPHP is very important to me and I will definitely be getting this accomplished 💯 |
|
I am back from holiday break and will be evaluating this for v3.6. I have taken about 3 attempts at this and have paused and deleted each time 🙃🔥 My challenge is I believe I need to compile FrankenPHP from source so I can maintain the "single source of truth" from the official Docker PHP images. I need to spend more time ensuring this is the way, since I haven't compiled a Go app in my life 😅 I will keep everyone posted once I have an update but please chime in below if you have any thoughts 🙏 |
|
@jaydrogers Not sure if this is feasible? The frankenphp images are based on the official docker images and add their stuff on top, so the php images would still be the source of truth? It’s additional work to keep the build working, which is done by the frankenphp maintainers anyway. Since it’s based on official docker images, you should be able to do anything you want with the frankenphp images, don’t you? That being said, I have no deep understanding about what you’re adding, so my opinion might be invalid 😅 |
|
Thanks for chiming in! Yes, you're totally right -- and I've tried this path. This might be a complicated for a single GitHub issue post, but here is an attempt on simpliying a few critical background parts:
If a new version of PHP is made available and FrankenPHP hasn't released that version yet, the build will fail. This adds two layers of dependencies for all Server Side Up images (if they are FrankenPHP or not):
This is where I hit my head against the wall and decided to take a break and circle back later 😃 I believe my latest theory was to use Multi-stage builds take the official build PHP image, check out a specific version of FrankenPHP, then compile it following their methods -- but I don't want to re-invent the wheel on compiling either 😅 Full build processdocker-php/.github/workflows/service_docker-build-and-publish.yml Lines 41 to 169 in 4807f98
|
|
@jaydrogers Thanks for the explaination, I definitely see your point. I guess it’s a trade of between path a) or b) where both require extra work then 😅 If it where up to me to decide, I'd probably add the additional dependency of frankenphp to the automated pipeline: Additionally check the frankenphp releases and only build this flavour of serversideup if the release is available. Again I might be missing something from a lack of knowledge. Also the frankenphp images apparently are automatically built when a new php image is available: https://frankenphp.dev/docs/docker/#updates |
|
I like @thomasaull's suggestions above. I'm re-evaluating switching back to serversideup/php since things have improved a lot since my last evaluation and I was just considering if there was a frankenphp variation as I personally use caddy in my own image and would like to keep using a caddy variant over nginx or apache. |
|
@jaydrogers - eager to get this going I've decided to give you a hand. Here's a PR that gets us a bit further down the road. #527 |
|
@jaydrogers I've been thinking about your dependency problem and I think you should build off the official frankenphp image rather than build franken yourself. According to this link: https://frankenphp.dev/docs/docker/#updates Like yours, the images will be built automatically with each PHP released. So I think probably you should have the images build independently of each other so the whole build doesn't fail. Regarding the images apparently the tags follow this pattern: You can either query the dockerhub api via curl and some scripting magic or use this tool. Script adapted from the internet. Just some thoughts. Very happy to help out. If you want some more in depth discussion or a sounding board on it let me know. I haven't delved very deep into your build process as yet. |
|
Hi, any update on this? |
I think @jaydrogers has been quite busy. So have I. It's certainly not forgotten. I will be needing this soon also. |
|
Hi, @jaydrogers . Any roadmap or updates on this? 😄 |
|
Haven't forgotten. Working on a big update that's related to this, then I will swing back. Stay tuned 😃👍 |
|
Just checking in on this, thanks! |
|
I'm out of the office this week, but I plan on doing serversideup/php items once I get back next week 👍 |
|
Do you need some help on this? I have some time next week to pick this up if needed. |
…sion 4 This new documentation outlines the migration process, highlights new features, and provides a checklist for users transitioning from version 3 to version 4, ensuring a smooth upgrade experience without breaking changes.
…names explanation This update introduces a new section on service names in Docker Compose, detailing how to define and reference services in the `compose.yml` file. It includes examples for clarity and improves the overall understanding of container management.
… guidance This update expands the section on using Docker with WordPress, emphasizing security optimizations, compatibility challenges, and recommended practices. It includes detailed explanations of deployment strategies and the importance of adhering to WordPress conventions for better plugin compatibility.
… for clarity and impact This update enhances the introductory content for the serversideup/php Docker images, emphasizing their production readiness, security, and performance optimizations. It also updates button labels and section headings to better reflect the content and improve user engagement.
…anced configuration details This update enhances the section on running Laravel queue workers with Docker, emphasizing the use of Artisan commands and the importance of graceful shutdowns. It also introduces advanced configuration options for managing multiple processes within a single container.
…and best practices This update clarifies the process of running Laravel Horizon with Docker, emphasizing the use of Artisan commands, the necessity of a running Redis instance, and the importance of graceful shutdowns. Key points for configuration and health checks are also introduced to improve user understanding.
This update enhances the section on running Laravel's task scheduler in Docker, emphasizing the use of the `schedule:work` command instead of `cron`. Key points regarding service configuration, graceful shutdowns, and defining schedules within Laravel are also included for better user guidance.
This update introduces tips for running multiple processes within a single container for both queue workers and Horizon, emphasizing the use of S6 Overlay scripts. Additionally, it clarifies the role of the `schedule:work` command in the task scheduler section, improving overall guidance for users working with Laravel in Docker environments.
…processes in Docker This update standardizes the tips for managing multiple processes within a single container across various sections, including task scheduler, queue, Horizon, and Reverb. It emphasizes the use of S6 Overlay service scripts and provides clearer instructions for users running `fpm-nginx` or `fpm-apache`, improving overall documentation consistency and usability.
…redundant details on Debian and Alpine
… practices of running containers as non-root users. Added sections on implications for web server ports and file permissions, along with recommended methods for running services on standard HTTP/HTTPS ports.
…ration (#608) Co-authored-by: Jay Rogers <3174134+jaydrogers@users.noreply.github.com>
…irst design, health checks, production-grade configurations, and orchestrator deployments. Added information on environment variable consistency and support for multiple operating systems, emphasizing best practices for production environments.
|
I just wanted to leave a note to acknowledge how grateful we are for our community. This project has been quite the journey, and it was totally worth the effort thanks to everyone who stepped up to contribute and test. You're all incredible and brilliant people, and we've learned so much through this release. We're truly grateful for every single one of you who has been part of this journey. With that being said, this PR is finally being merged into stable today. We're beyond stoked to see where this release takes the project next. Thanks for all your hard work ✌️ Let's go PHP! 🚀 |
|
What is the equivalent image of serversideup/php:cli using frank? |
|
You can use I recommend taking a look at this: https://serversideup.net/open-source/docker-php/docs/getting-started/choosing-an-image If you have any other questions, let me know. Feel free to open a discussion with your questions. I am going to lock this thread so we don't bother all the people subscribed to this older PR. |
4.0 Release: Say hello to FrankenPHP 👋
🚀 What this PR does
This PR is our home base for testing our new 4.0 release. This adds the highly anticipated variation of FrankenPHP and further optimizes serversideup/php to be highly optimized for deploying and maintaining Laravel applications.
🫵 WE NEED YOU: Help us test test this release
Important
Please keep reading the notes in this post before cowboy coding and throwing this into production 🤠
php-dev(notphp)View Test Images on Dockerhub →
Anything tagged with
283-will reference this PR and should be tested. Notice we're testing onphp-dev(notphp).🐛 Reporting Issues
👨🔬 What to test
We really need the community's help on testing these images as we progress towards stable.
1️⃣ All variations: Laravel Automations
There were huge improvements made to the 50-laravel-automations.sh script.
2️⃣ FrankenPHP: Caddyfile structure
LOG_LEVEL_OUTPUThelp you out? Are the logs too noisy?3️⃣ Test start up scripts
We made improvements to the entrypoint script.
🌎 Latest Documentation
Use the link below to reference the latest documentation (it will automatically update as we keep improving the docs).
View the latest documentation →
😅 Breaking Changes
exit 0coming back. We made changes to the subshell stuff. You can learn more about why we did this in /etc/entrypoint.d if script ends withexit 0no other scripts are executed #481✋ Deprecation Notices
⚡️ What's new
🧟♂️ FrankenPHP variations now added
The highly anticipated release of FrankenPHP is now available. These images come with many enhancements compared to the official FrankenPHP images.
Images are unprivileged by default
For best security practices, we're running things as
www-data. This dramatically reduces your security footprint when running PHP in production. Because of this, we're listening on8080 (HTTP)and8443 (HTTPS). This follows the same design pattern as our other images.Native health checks
Health checks are critical for ensureing zero-downtime deployments. Our images come "batteries included" with intelligent health check endpoints that can easily be customized with
$HEALTHCHECK_PATH. By default, our images ensure/healthcheckis alive with Caddy, but you can change this variable toHEALTHCHECK_PATH=/upand it will use the built-in Laravel health check endpoint to ensure Laravel is actually ready to accept requests.Extremely flexible and production-grade Caddyfile by default
The default FrankenPHP Caddyfile gives you enough to get started, but we spent a ton of time making sure that we're shipping production-grade and secure configurations by default. This includes:
Designed for mass-scale production deployments
It's almost unbelievable and amazing how well FrankenPHP works with Caddy as a proxy. This tight integration allows you to do magical things like deploy trusted SSLs with Let's Encrypt. The only problem is, you probably have something else serving SSL termination and you most likely would not use that feature in a single container.
Our approach is "orchestrator first", meaning the image is designed for mass-scale in mind.
This means we're shipping the image assuming that you're doing TLS termination elsewhere. This makes it easier for you to scale and perform zero-downtime deployments:
flowchart TD A["Reverse Proxy (Not FrankenPHP)"] -->C{Container Service} C -->|STOP| D[MyApp:v1] C -->|START| E[MyApp:v2]Flexible environment configuration
Just like the experience with our other PHP variations, we also have things like
SSL_MODE,LOG_OUTPUT_LEVEL, changing PHP INI settings with environment variables, all our helper scripts for changing permissions, etc. that make it a breeze for you to customize how the PHP image behaves.More operating system variations
We are able to compile FrankenPHP by source, which allows us to open up support for many operating systems.
How tagging works
There's more to it, but in general the primary principle is:
{php-minor-version}-{variation}-{os-version}This means we're offering FrankenPHP with the following operating systems:
trixie: Debian Trixie (13)bookworm: Debian Bookworm (12)alpine3.22: Alpine 3.22alpine3.21: Alpine 3.21🚀 Laravel Octane Support
Laravel Octane is now natively supported with our FrankenPHP variation. We created a native health check script to ensure your container is healthy when running Octane and also documented how you can add Octane to your project.
🌐 New Documentation Site
We completely rewrote our documentation site and improved the user experience dramatically. Not only did we add a ton of new documentation, we used many native Nuxt Content components to improve the experience when reading the docs.
It also includes native LLM integration 👀
🤩 New Features
Laravel Automations Script Improvements
The Laravel Automations script has been completely refactored to make it easier to support advanced Laravel features. Tons of new features are now available:
"php artisan optmize" now run by default
Instead of setting
AUTORUN_LARAVEL_ROUTE_CACHE,AUTORUN_LARAVEL_VIEW_CACHEetc, we useAUTORUN_LARAVEL_OPTIMIZEby default, which callsphp artisan optimize. Readjusting our logic to this new structure not only simplifies our approach to follow Laravel's best practices, it allows you to hook into the optimize command if you need to use it for your own application.If you don't want to use
php artisan optimizeor if you're running an older version of Laravel, no sweat! Our refactored approach is backwards compatible and you can enable/disable certain functions by just setting your desired values toAUTORUN_LARAVEL_ROUTE_CACHE,AUTORUN_LARAVEL_VIEW_CACHEetc.Added support for "migration modes"
We now support different migration modes of
refreshorfreshby Laravel. This is super helpful if you need to seed a preview environment.default(our default behavior)php artisan migrate- standard forward migrationsfreshphp artisan migrate:fresh- drops all tables and re-runs migrationsrefreshphp artisan migrate:refresh- rolls back and re-runs migrationsSpecify which database connections to run migrations with
If you run multiple databases with a multi-tenant Laravel application, you may need to specify your exact database connection that you'd like to use. We created
AUTORUN_LARAVEL_MIGRATION_DATABASEso you can set the configuration name of the database connection you'd like to run migrations on (ie.mysql). Supports running against multiple databases too (ie.mysql,pgsql).Added "--seed" option to migrations
Laravel has a helpful flag of
--seedthat you can run with php artisan migrate that will indicate if the seed task should be re-run. If you need this, just setAUTORUN_LARAVEL_MIGRATION_SEEDtotrue.Easier debugging
If you're running into issues with automations, set
AUTORUN_DEBUGtotrueand you'll get helpful output to help you figure out why you're running into issues.Control NGINX IP listening protocols with
NGINX_LISTEN_IP_PROTOCOLAre you running an IPv6 only cluster with fpm-nginx? Now you can set
NGINX_LISTEN_IP_PROTOCOL: ipv6and NGINX will listen on IPv6 stacks only. Same thing works if you set it toipv4, then IPv6 will be disabled.Great for Kubernetes clusters! 🤓
Default behavior is to keep a non-breaking change of
allwhich will listen on IPv4 and IPv6.Change listening ports for NGINX and Apache
To mimic FrankenPHP + Caddy, we created
NGINX_HTTPS_PORTandAPACHE_HTTPS_PORTif you want to change the listening port of Apache or NGINX for any reason🧘♂️ Quality Of Life Improvements
Improved health checks
A brilliant PR by @aSeriousDeveloper was merged which dramatically improves our "definition of healthy", especially on container start up. This approach utilizes
start-periodandstart-intervalwhich will give us more accurate readings and flexibility for container start up.unhealthy.Startup and Entrypoint Scripts
entrypoint.dscripts so we can gracefully handleexit 0in a entrypoint scriptChanging file permissions (
docker-php-serversideup-set-file-permissions)--serviceis now optional)--dirparameter for specifying extra directories (you can specify multiple--dirflags for multiple directories)Quiet health check access logs
fpm-nginxandfpm-apachelogs to never show access log output for any request$HEALTHCHECK_PATH. Things are much quieter now 😃🐛 Bug Fixes
All images
session.sid_bits_per_characterandsession.sid_length(using PHP defaults now) (session.sid_bits_per_character INI setting is deprecated & session.sid_length INI setting is deprecated #560)exit 0(/etc/entrypoint.d if script ends withexit 0no other scripts are executed #481)S6-based images (
fpm-nginxandfpm-apache)docker-serversideup-php-s6-initback for advanced S6 dependency use cases (Custom s6 services dependencies no longer works #479)fpm-nginx
absolute_redirect off;to have redirects return relative redirects (helpful for proxies like Traefik) (Add absolute_redirect off; to prevent broken redirects in containerized environments #567)svgzwith Symphony's asset mapper with FPM-NGINX (Move SVG handling to media assets block for Symfony's Asset Mapper compatibility #530)/package/admin/s6-overlay/libexec/preinit: info: /run belongs to uid X instead of Ywhen using thedocker-php-serversideup-set-file-permisisonsscript on FPM-NGINX Alpine instancesrobots.txtnot passed to PHP #589)ondemandfor even lower resource usage by default (PHP_FPM_PM_CONTROL setting different from documentation #594)fpm-apache
ondemandfor even lower resource usage by default (PHP_FPM_PM_CONTROL setting different from documentation #594)⏫ Dependency updates
install-php-extensionsscript to v2.9.18🌎 New Environment Variables
The following environment variables are now available:
default/dev/stdout100M/dev/stderr80808443all/status0120nullOff