-
-
Notifications
You must be signed in to change notification settings - Fork 163
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
base: main
Are you sure you want to change the base?
Conversation
|
This would be super cool to have! Great work on this so far! |
Deploying serversideup-php with
|
| Latest commit: |
d5898c9
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://c34aaa1d.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. |
…iling the transition from development to production images, creating Dockerfiles, best practices, and image versioning strategies. This guide aims to enhance user understanding of building secure and reliable Docker images for production environments.
…se 'compose.yml' for consistency across task scheduler, queue, horizon, and reverb guides.
…' to 'compose.yml' for consistency in configuration examples.
…mpose.yml' instead of 'docker-compose.yml' across all examples.
…addressing common challenges and providing solutions for managing UID/GID alignment between host and container environments. This guide includes examples for development and production setups to enhance user experience and security.
…larity on user and permission management in development environments. Updated image path syntax for consistency and enhanced user understanding of file permission challenges across different operating systems.
…' with 'compose.yml' for consistency across examples.
…on using Docker. Covers deployment challenges, Docker benefits, production image building, deployment strategies, automation, and introduces Spin for simplified workflows. Aims to enhance user confidence in deploying PHP applications.
…yml' for consistency in configuration examples and improve clarity in Docker setup instructions.
… section title for better readability.
…cludes requirements, execution order, and examples for integrating scripts into the entrypoint.d directory, as well as guidance on using S6 Overlay for long-running services.
…s examples for using environment variables and custom php.ini files, along with validation methods to ensure changes are applied correctly.
…roduced icons for DigitalOcean, Hetzner, Vultr, and Sevalla, enhancing visual representation of hosting options in the application.
…ntainerized PHP applications. The guide covers portability, hosting options, recommended hosts, and key considerations for selecting the right host, enhancing user understanding of deployment strategies.
…documentation. Include a link to the guide on using healthchecks with Laravel for better user guidance.
…C_PATH` with `CADDY_SERVER_ROOT` for clarity and consistency. Adjust Caddyfile configuration to reflect the new variable, ensuring accurate root directory settings for the Caddy server.
…ER_ROOT` for improved clarity in server configuration.
…erversideup/php image. This includes usage guidelines, feature comparisons, setup instructions, and environment variable configurations, aimed at enhancing user understanding and adoption of this modern PHP application server.
…ng setup instructions, health check implementation, and performance considerations. Introduce a health check script for Octane to ensure proper application status monitoring.
…proved navigation. Adjusted paths to ensure they are correctly formatted for internal referencing.
…sure users are properly redirected when a page has a redirect property. This change enhances user experience by maintaining expected navigation behavior.
…the `SSL_PRIVATE_KEY_FILE` entry, enhancing clarity on supported configurations for HTTPS.
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 →
⚡️ 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🌐 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.
🌎 New Environment Variables
The following environment variables are now available:
default/dev/stdout100M/dev/stderr80808443all/status0120nullOff🤩 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.🧘♂️ 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)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 instancesfpm-apache
⏫ Dependency updates
install-php-extensionsscript to v2.9.11✅ Jay's Checklist
These are notes to myself so I can remember where I left off as I start merging more things in:
Development
LOG_LEVEL_OUTPUTCaddyfileto work like ourfpm-nginximagePHP_environment variables from other Server Side Up images to work with FrankenPHPset-idandset-filepermissionsscripts work well$HEALTHCHECK_PATHDocumentation