- 21
- 144 438
Chris Fidao
United States
Registrace 18. 12. 2010
🎥 about coding and servers. Laravel forever!
Leveling up Laravel deployments: Unlocking optionality
This is how I like to do deployments for Laravel applications.
This involves using a CI pipeline, instead of (blindly) deploying based on git webhooks.
There's a lot of reasons why deployments can get bogged down and, frankly, suck. Let's see how to get unstuck by adding some process to our deployments.
The two main things that buy you optionality are:
1. An approval process
2. A deployable build artifact
These gives you lots of options! You can prevent bad code from going to production with an enforced approval process. When a build artifact, you can run your code from different points in time (without having to worry about nodejs dependency issues), test out other platforms, build containers, and run all sorts of experiments with little hassle.
Check out the same repository: github.com/fideloper/deploy-me
⌚️ Timestamps
00:00 Deployments: Complicated!
00:35 Why optionality?
01:30 You need a CI pipeline
01:54 GitHub Action setup (approval)
04:18 Build a deployable artifact
06:35 Need your feedback
This involves using a CI pipeline, instead of (blindly) deploying based on git webhooks.
There's a lot of reasons why deployments can get bogged down and, frankly, suck. Let's see how to get unstuck by adding some process to our deployments.
The two main things that buy you optionality are:
1. An approval process
2. A deployable build artifact
These gives you lots of options! You can prevent bad code from going to production with an enforced approval process. When a build artifact, you can run your code from different points in time (without having to worry about nodejs dependency issues), test out other platforms, build containers, and run all sorts of experiments with little hassle.
Check out the same repository: github.com/fideloper/deploy-me
⌚️ Timestamps
00:00 Deployments: Complicated!
00:35 Why optionality?
01:30 You need a CI pipeline
01:54 GitHub Action setup (approval)
04:18 Build a deployable artifact
06:35 Need your feedback
zhlédnutí: 1 867
Video
Surviving Homebrew: 9 tricks to master (and debug) Brew
zhlédnutí 857Před 6 měsíci
We become Brew power users, learning 9 tricks to better make use of Brew, and debug issues that come along with using it. We laugh, we cry, we poke fun. Everyone has a good time. ⌚️ Timestamps 00:00 Intro 00:30 Where is everything? 01:15 Brew Services 01:51 Brewfile 02:28 Brew hell: Installing/Updateing 03:44 Brew Doctor 04:17 Permissions 05:08 Brew Mas 05:47 Brew (un)link 06:35 Brew Edit 7:07 ...
The secret behind FrankenPHP: Will it revolutionize PHP?
zhlédnutí 40KPřed 7 měsíci
How to use FrankenPHP to ship your PHP/Laravel application, in a way that's potentially revolutionary and definitely pretty magical. FrankenPHP is a PHP application server, written in Golang. It's a module for the Caddy web server. Behind the scenes, Franken acts as a PHP SAPI (the thing that site between your web server and your PHP application). It manages handling PHP processes that result f...
Public routes blow up Laravel (in a weird way!)
zhlédnutí 16KPřed 7 měsíci
Public routes can grind your Laravel app to a halt. See why and how to fix it! A public "asset" route is one created dynamically in your Laravel code base, but serves “static asset” such as an SVG or JS embed meant to be used by your users/customers. However this means any traffic your customers get, you get (since they’re serving up YOUR asset on their site)! There’s two ways this breaks Larav...
Run Laravel in a subdirectory with Nginx (full, working config)
zhlédnutí 2,3KPřed 7 měsíci
We get Laravel working in a subdirectory, using Nginx configuration. This is great for multiple Laravel installations, or when you just have a second Laravel running inside of any subdirectory. The Laravel code base is not literally in a subdirectory of a parent code base, instead we just use Nginx routing to make the URL routes behave as if it is. ▶ The original content for this article is her...
Nginx Wildcard Subdomains for Multi-Tenancy (ssl + better config)
zhlédnutí 2,4KPřed 7 měsíci
We use letsencrypt (certbot) with the CloudFlare DNS plugin to generate a fee, auto-renewing TLS certificate to use with Nginx. Then we configure Nginx to use that TLS certificate and create a configuration to support multi-tenancy in our applications. We use a special configuration to capture the value of the subdomain so we can pass it off to our PHP application (or do anything we want, like ...
SSL Certificates in 30 Seconds
zhlédnutí 1,9KPřed 8 měsíci
See how to install, setup, and configure LetsEncrypt (certbot) with Nginx to get an SSL certificate in something like 30 seconds. This will help you get and configure an TSL certificate that auto-renews itself via LetsEncrypt - you never have to think about it again! When you install certbot, it will add a systemd timer. This timer periodically checks if the certificate needs renewing, and if s...
Production Ready Nginx, fixing Nginx's Default Configuration
zhlédnutí 19KPřed 8 měsíci
We take Nginx's default configuration and ensure we properly setup caching and security settings so we can serve our applications under the most idea circumstances. This makes use of H5BP's Nginx Configuration to quickly and easily get Nginx setup for production. H5BP: github.com/h5bp/server-configs-nginx ⌚️ TIMESTAMPS 00:00 Intro 00:26 Nginx’s Problematic Defaults 02:30 Fixing Nginx w/ H5BP 03...
Understanding and Debugging Nginx Configuration
zhlédnutí 922Před 8 měsíci
We take a tour of Nginx configuration to help you figure out and debug issues. We see where configuration is, talk about configuration conventions, seeing how to view loaded Nginx, test Nginx configuration, and finally understand a basic server configuration (to host your sites)!. Keep an eye out for future, more in-depth videos, especially regarding Nginx for Multi-tenant application setups (e...
Shipping Docker Course (re)Introduction
zhlédnutí 373Před 8 měsíci
I'm updating the Shipping Docker course ahead of Black Friday in 2023. courses.serversforhackers.com/shipping-docker This is my most sucessful course! It's also the oldest! It's still super relevant tho - luckily Docker hasn't changed under my feet. I've made a bunch of updates for 2023 and I talk a bit about why I didn't feel the need (at all!) to completely redo the course! If you want to hea...
Local dev setup for multi-tenant applications
zhlédnutí 2,1KPřed 8 měsíci
I'm doing some videos on setting servers up for multi-tenant applications. This means letting each customer/user have their own subdomain within your application. To start, we setup our local dev environment to use dnsmasq nginx to: 1. Map the domain used to a directory (where our code lives) 2. Setup specific apps to run with ANY subdomain so we can test a multi-tenant setup locally ⌚️ Timesta...
The surprising ways Nginx try_files actually works
zhlédnutí 1,5KPřed 9 měsíci
We see how Nginx's try_files directive actually works. It seems super simple at first, but there are configuration settings that affect how it works! We'll see what other configuration we should care about, and how other Nginx location blocks can be used in conjunction with try_files. ⌚️ Timestamps 00:00 Intro 00:08 URI and the Document Root 01:01 What try_files does 02:27 Other location blocks...
PHP is Weird, Stateless, and Beautiful
zhlédnutí 22KPřed 9 měsíci
HTTP is stateless. Most languages and frameworks are not! PHP, however, is a weirdo. It was created for HTTP! Unlike other languages, PHP rebuilds it's entire world on each request. This is a beautiful thing. ⌚️ Timestamps 00:00 PHP is Stateless 00:09 HTTP is stateless, too 01:22 Comparing Languages 04:28 The People's History of PHP 05:22 Ancient PHP looked like this 06:41 What's your point? 07...
Nginx Unit changes how we host PHP (& Laravel)
zhlédnutí 20KPřed 10 měsíci
Nginx Unit changes how we host PHP (& Laravel)
How Nginx and PHP-FPM turn a web request into code
zhlédnutí 3,7KPřed 10 měsíci
How Nginx and PHP-FPM turn a web request into code
Configuring and Troubleshooting PHP-FPM
zhlédnutí 4,2KPřed 10 měsíci
Configuring and Troubleshooting PHP-FPM
What to do when you hit 502 or 504 gateway errors on your Laravel app
zhlédnutí 2,6KPřed 11 měsíci
What to do when you hit 502 or 504 gateway errors on your Laravel app
Setting your $PATH variable for Laravel development
zhlédnutí 341Před 11 měsíci
Setting your $PATH variable for Laravel development
Good video but you completely forgot to include anything about debugging which was supposed to be the point of the video
you can use cloudflare for SSL also ?
certainly, and that pairs well with their origin certs so the connection is encrypted end to end!
Great explanation. No fluff. No boilerplate cluttering the examples.
thanks!
Great content. Keep 'em coming please!
I already have nginx server on my ubuntu 22.04 running for several project, I want to try nginx unit for my newest project, if I install this nginx unit, would it break my nginx and all related website?
i don’t think so - but i’d experiment in a docker container first.
I remember yhe good old times when it was considered bloated if the executable exceeded a few megabytes in size :) oh how the turntables have been turning ;D
definitely not my favorite part of it. Interestingly golang can pretty easily get large too!
There is no revolution or magic here to be found! It is not worth to study how this works internally, reading documentation for hours etc. Use docker and apache,nginx. Keep it as simple as possible.
Franken php to bundle backend, and deno (hopefully bun too) to bundle and deploy frontend. Maybe someone can come up with installer script for windows, shipping products is going to be smooth as f in future.
Hi. I'm trying to run the frankphp in a different port. Is it possible to specify a port different from default (80) on run it? Thanks
unsure! did you figure that out? (in their docs?)
@@fideloper I didn't find anything. I forgot to mention... I'm talking about the standalone binary, not about the docker version
Awesome, neat and easily put across! Can you make a video auto ssl for external domains, something what Shopify does?
i’d use cloudflare 😂 - check out “cloudflare for saas”
Thanks for the great tutorial. I just setup Laravel with Tenancy package, but I get a different behavior on Herd; the tenant app loads the landlord home page. Maybe this is as a result of the folder structure on Laravel 11. Edit: This doesnt happen in laravel10. My guess is because the folder structure is exactly as on the documentation of the tenancy Package and I followed all steps as supposed :) Thanks once more for the great video.
Why that door moved from right side to left side 😆😆
How would the Laravel task scheduler be setup ? Will it leverage the existing binary or will you need to install PHP on the host machine and setup a cronjob?
you can use the existing binary to run any command
docker run --rm -v $PWD:/app -p 443:443 dunglas/frankenphp php artisan sapi ERROR Command "sapi" is not defined. How come you did not get this error ?
Excellent!!!
Required reviewers are only available for public repositories.
kinda lame, but I guess in theory if you use GH for business…pay for it!
Is it best than swoole ?
nothing is best or worst... its a very shallow way of thinking... you should ask, best for X or Y
the wink about 6mins in got a chuckle out of me
Crazy. I was just about to use Nginx Unit with PHP inside one container and now I see this.
it’s worth experimenting to see which you like better! Since Franken uses caddy, i think you get more configuration (it’s a full web server, i think Unit has less features)
Nice explanation
thanks!
What about logging and other stuff when you build the binary ?
they get spit out through the processes stdout, which you can direct to a file or ship to whatever logging mechanism you want (this is standard for non-php things, php was always the weirdo for really only having a file-based option)
This is awesome!
Took me a day till i found this
glad it was helpful!!
Just awesome explaining.... You're rocks
Thank you so much 😀
finally even PHP can suffer from a complex zero downtime deployment - thanks to single binaries.
ohhh interesting, what’s the complexity? what’s different from other deployment methods?
I think putting it architecturally side by side with nginx + fpm could provide clarity, thanks for sharing, cheers!
how does it compare with preloading, JIT...etc ?
how do u deal with pecl extensions? that are not listed in the bash file ?
You can set up the mentioned envs. With it, you can specify a minimal list of your extensions. Notice, that they use static-php-cli to build the static PHP. FrankenPHP, as its name suggests, is just tailored of various components.
i wanted to ship a mysql server as well , does it bundle that as well?
this isn’t a whole server, nope! Think is this as just rubbing your app code, no database or anything else
When I am looking at any web stuff I can't believe that it is a binary code. It is super slow and absolutely religious by it's nature. While it is for the most part just an implementation of a prefab concept with a declarative language + some language that is targeting simple projects (getting problematic later). And overall everything web purposed is very similar to a game engine scope. I would expect true revolution for web with something like web-engine with specific IDE and editor. Game engine is an example of how you have an environment that is ready for all sorts of typical stuff and solutions for them in one place. And you don't have to remake everything if you just want to replace a physical engine or rendering pipeline. In few words: to have an actual architecture and not just bunch of unrelated stuff glued together hoping for the best. But I am quite delusional about web as I don't like browser and websites in the first place.
Hello my name is Guilherme I'm from Brazil, I'm interested in your course, do your videos have subtitles? With subtitles in English I can understand almost anything, without subtitles is a bit harder...
they don’t, but I should see if I can update them 🤔
I've recently implemented my CI pipeline within AWS itself.. I noticed you didn't even mention AWS as an option yet you mentioned 6 or 7 others.. you're making me doubt my choices now.. is AWS for CI not a good idea?
I'm currently having this problem and this video solves it. Thank you for the great video and great explanation!
awesome!
C.I. it`s a art! 🤓
I like your style, however your artifact has compiled built code (with npm packages), that was created via a node version. You stated that you can go back and not have to worry about NPM. This is not totally true as you will still need to deploy that artifact into an environment which is able to run in (a different NPM or node version may still make it fail). Clearly there are ways around this - like using a docker build file, making sure that is tracked as well. But then this also means you know the code will run on that tagged image version (correct NPM and node versions) your artifact though speeds up the reverting to an old build and WORST.. a package going offline so you can't install it again. Again only a small point, I don't use artifacts enough at the moment and will be moving to this. Approval stage is also great, to often code goes out that shouldn't. However I do also employ protected branches, so merge requests must be completed with a reviewer. The advantage you have, is that your test / build stage has generated an artifact, that is then a lot faster to deploy. Keep up the great content.
thanks! In this case (not all cases for sure) you already have built the static assets so you probably don’t need node again in production to rebuild all those assets. Of course if you also run some node process alongside your laravel app, then you’ll need node in production as well.
Your last chapter reminded me of people, and perhaps me the most, spending hours upon winning two milliseconds in context of nginx vs caddy, when a relationship query is taking 500ms 🤣🤣
Don't forget the folks who always struggle with the auto-cert with Nginx.
Is the deploy only after review only available in Enterprise GitHub or is the setting something I am missing in our organization account?
I believe it’s available on public repos or private paid org repos (the environment feature, that is). See the note here: docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment
@@fideloper it looks like on my plans " If you are on a GitHub Free, GitHub Pro, or GitHub Team plan, required reviewers are only available for public repositories. " still working on some ways to add this for our small shop. Loving this new series of videos by the way.
what is this value "$GITHUB_SHA"?
that’s the git commit sha (a git thing, not specific to github)
But I mean. Docker already is something you use to be able to deploy things in an easier way. If I have a dockerized application I can deploy it to any cloud environment like aws, azure etc with docker integration. I don't see the point
Chris: "Does anyone use Travis CI anymore?" Me: 🤣 Good stuff!
and no one’s feelings got hurt! probably!
I'll argue that having 2 separate branches for 2 environments (e.g. develop -> staging, main -> prod) is infinitely better than the workflow you presented, even if you're the only developer.
That's definitely how I've done it the most myself as well! I'm very curious about what setups others have.
Care to explain the benefits of having multiple branches per environment? I am mostly using GIT FLOW as an approach and it can be bothersome for small projects. Though using feature branches is an approach I enjoy.
My 2 cents is that it was practical knowledge. I usually have a staging & main/master branches where those are both protected and requiere a review process before merging the PRs which triggers the CI/CD pipeline for release to prod upon merging. This enforces a workflow of PRs but does not protect from rogue commits to main/master unless you have that setup in github or git hooks (still can be bypassed) But I don’t feel like I need to start worrying about direct commits to the main branch or out of the blue force pushes to master branch,regardless this was a bit out of topic. This approach seems to introduce an additional layer of validation process which in a certain scenarios may come in handy.
👌 *Promo sm*
i not understand that the part when you can give others to run immediately. 1. does it can run on others developer local machine on windows when it is develop in ubuntu OS without having composer npm node all those sort thing? 2. how to run it on other machines?
it has everything built in , so no need to run “composer install” nor “npm o stall && npm run build”, basically you can just give someone a working code base (they’d need php and stuff to run it).
This is coming at the right time 👌. Great job
nice! 🤝
Great stuff, keep it going! 💪
thanks!! really appreciate it
Check out the repository for the code! github.com/fideloper/deploy-me
How the process / the php app is kept alive or restart if chashes? Thanks
depends how you deploy it but in general it’s setup to handle that
This looks insane… if you have any sort of app that is moderately complex we should test the $&@T out of it and see if it’s faster, concurrent requests and page loads on dinámica content etc etc… would love to see a deep dive on server deployment
how easy is this to use with ssl? manual and automatic systems like letsencrypt?
caddy (via certbot) attempts to setup ssl for you! you can tell it not to if you’d like, but in theory you can configure caddy however you like