<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Jorge Santos</title>
    <description>The latest articles on Forem by Jorge Santos (@jdsantos).</description>
    <link>https://forem.com/jdsantos</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F91693%2Fd0435d34-f61e-45e2-a3d2-a464aa197cfd.png</url>
      <title>Forem: Jorge Santos</title>
      <link>https://forem.com/jdsantos</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/jdsantos"/>
    <language>en</language>
    <item>
      <title>How I deploy Laravel apps in Docker with just two commands</title>
      <dc:creator>Jorge Santos</dc:creator>
      <pubDate>Sat, 07 Sep 2024 20:54:00 +0000</pubDate>
      <link>https://forem.com/jdsantos/how-i-deploy-laravel-apps-in-docker-with-just-two-commands-2cjl</link>
      <guid>https://forem.com/jdsantos/how-i-deploy-laravel-apps-in-docker-with-just-two-commands-2cjl</guid>
      <description>&lt;p&gt;Hi there! It's Jorge. It's been a while since my last post, and this one might sound the same as &lt;a href="https://dev.to/jdsantos/laravel-10-nginx-php-fpm-my-ready-to-use-all-in-one-recipe-for-your-laravel-10-deployment-in-docker-18lb"&gt;one that you might have read around here&lt;/a&gt;. But come along and I promise you that you never again will have to build docker images from scratch to your &lt;a href="https://laravel.com" rel="noopener noreferrer"&gt;Laravel&lt;/a&gt; projects!&lt;/p&gt;

&lt;h2&gt;
  
  
  ⚡TL;DR
&lt;/h2&gt;

&lt;p&gt;Tired of configuring Docker from scratch for every Laravel project? &lt;a href="https://github.com/jdsantos/laradocker" rel="noopener noreferrer"&gt;This is the link to the Github repository for the Laradocker project&lt;/a&gt;, a brand new composer package that sets up your Laravel project with Docker with just these two simple commands:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;


&lt;span class="c"&gt;# Run these commands inside your Laravel project:&lt;/span&gt;

composer require &lt;span class="nt"&gt;--dev&lt;/span&gt; jdsantos/laradocker

php artisan laradocker:install

&lt;span class="c"&gt;# That's it! Follow the instructions and you are done!&lt;/span&gt;



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;On your way there, please leave a star ⭐ on the repo to show your support. &lt;/p&gt;

&lt;p&gt;Thanks in advance ❤️&lt;/p&gt;

&lt;h2&gt;
  
  
  📜The backstory
&lt;/h2&gt;

&lt;p&gt;In my &lt;a href="https://dev.to/jdsantos/laravel-10-nginx-php-fpm-my-ready-to-use-all-in-one-recipe-for-your-laravel-10-deployment-in-docker-18lb"&gt;previous post&lt;/a&gt;, I brought you &lt;a href="https://github.com/jdsantos/laravel-alpine-nginx-phpfpm-opcache-docker" rel="noopener noreferrer"&gt;LANPOD&lt;/a&gt; a Laravel/Docker deployment strategy that allows you to deliver a Laravel app on-premise or cloud environments relying on a battle tested tech recipe consisting of &lt;strong&gt;laravel + alpine linux + nginx + php-fpm + opcache + docker&lt;/strong&gt; you absolutely loved.&lt;/p&gt;

&lt;p&gt;This recipe allows you to deploy your app in a redistributable, virtualized, os agnostic, self-contained and self-configured software image and run it in virtualization engines such as &lt;a href="https://docker.com" rel="noopener noreferrer"&gt;Docker&lt;/a&gt; or &lt;a href="https://podman.io" rel="noopener noreferrer"&gt;Podman&lt;/a&gt;. It even includes things out of the box like the supervisor's tidy configuration for handling your queues, nice defaults for php, opcache and php-fpm, nginx, etc.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;All good, but...&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  😵The pain
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Something was off.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While LANPOD as a template repository on Github was a helpful starting point for a brand new Laravel app, and a &lt;strong&gt;LOT&lt;/strong&gt; better than having to go about wiring virtualization over and over again on the same structured apps, it was completely useless to an already existing/legacy project. You would have to &lt;strong&gt;MANUALLY&lt;/strong&gt; extract the recipe’s files and directories of the bunch of other stuff, and adapt them to your needs. As it was meant to be a template-only repository, it didn’t include right out of the box any native database support (because if it did, it would have to include all of them in the same image), and if an update to the configuration was needed, it would be hell on earth just to know how and what to change in your project.&lt;/p&gt;

&lt;h2&gt;
  
  
  💊The solution
&lt;/h2&gt;

&lt;p&gt;Having felt this pain myself enough times already, especially when having to add by hand the database dependencies to the Dockerfile/Containerfile over and over again, I realized: how cool would it be to have this recipe as a dependency in my projects, in such a way that is easy peasy to install, uninstall and update in the future?&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;"That's it! I'm going to create a Laravel package that I can install in my projects! Let's do this!"&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp76bx3riolr5lq2tgjkz.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp76bx3riolr5lq2tgjkz.gif" alt="Adventure gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So, the adventure began!&lt;/p&gt;

&lt;p&gt;I started to scaffold my brand new composer project with all required dependencies to develop and test Laravel packages including &lt;code&gt;orchestra/testbench&lt;/code&gt;, &lt;code&gt;laravel/pint&lt;/code&gt; and &lt;code&gt;larastan/larastan&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;After that, I set up right from the start a &lt;a href="https://github.com/jdsantos/laradocker" rel="noopener noreferrer"&gt;Github repository&lt;/a&gt; for the project, auto-publish capabilities to &lt;a href="https://packagist.org/packages/jdsantos/laradocker" rel="noopener noreferrer"&gt;Packagist&lt;/a&gt;, the PHP composer package repository, and spawned Github actions for a super simple CI/CD pipeline to run my tests at each push.&lt;/p&gt;

&lt;p&gt;With all this in place, the rest was peanuts: I used all of &lt;a href="https://github.com/jdsantos/laravel-alpine-nginx-phpfpm-opcache-docker" rel="noopener noreferrer"&gt;LANPOD&lt;/a&gt;'s files as mere stubs for this project, and used the plain &lt;a href="https://laravel.com/docs/11.x/artisan" rel="noopener noreferrer"&gt;Artisan Console&lt;/a&gt; to develop a pretty silly and basic UI for installing this recipe:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy1yucy96v3ddi0h5gz20.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy1yucy96v3ddi0h5gz20.png" alt="Terminal UI"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After launching Laradocker inside your project, the installer will guide you through the necessary steps to build the proper dependencies in the image, such as database connectivity support and you are done! &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5lfx65jd7kacp5uj15tu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5lfx65jd7kacp5uj15tu.png" alt="Databases"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;All files get generated in an instant and copied into your project!&lt;/p&gt;

&lt;h2&gt;
  
  
  👨‍💻The code
&lt;/h2&gt;

&lt;p&gt;This package is completely free &amp;amp; open-source and &lt;strong&gt;&lt;a href="https://github.com/jdsantos/laradocker" rel="noopener noreferrer"&gt;you can find the source code here!&lt;/a&gt;&lt;/strong&gt;. On your way there, please leave a star ⭐ on the repo to show your support. &lt;/p&gt;

&lt;p&gt;Thanks in advance ❤️&lt;/p&gt;

&lt;h2&gt;
  
  
  💻 Environment
&lt;/h2&gt;

&lt;p&gt;This was the environment that I used:&lt;/p&gt;

&lt;p&gt;Hardware&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Intel i7-8750H&lt;/li&gt;
&lt;li&gt;  24 GB of RAM&lt;/li&gt;
&lt;li&gt;  SSD 250GB&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Software&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Windows 11 Enterprise&lt;/li&gt;
&lt;li&gt;  Docker Desktop with WSL backend&lt;/li&gt;
&lt;li&gt;  Visual Studio Code&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hope this helped you in any way.&lt;/p&gt;

&lt;p&gt;See you soon! 👋&lt;/p&gt;

</description>
      <category>docker</category>
      <category>laravel</category>
      <category>nginx</category>
      <category>php</category>
    </item>
    <item>
      <title>Laravel 10 + NGINX + PHP-FPM - my ready to use all in one recipe for your Laravel 10 deployment in Docker</title>
      <dc:creator>Jorge Santos</dc:creator>
      <pubDate>Sat, 17 Feb 2024 00:00:00 +0000</pubDate>
      <link>https://forem.com/jdsantos/laravel-10-nginx-php-fpm-my-ready-to-use-all-in-one-recipe-for-your-laravel-10-deployment-in-docker-18lb</link>
      <guid>https://forem.com/jdsantos/laravel-10-nginx-php-fpm-my-ready-to-use-all-in-one-recipe-for-your-laravel-10-deployment-in-docker-18lb</guid>
      <description>&lt;p&gt;Hi there! It's Jorge. Is it just me, or did January felt like it had 90 days or so? Well, nevermind. Let's dive right in on what brought you here.&lt;/p&gt;

&lt;p&gt;In this post, I'm continuing on the Docker + Laravel theme but now on a diferent topic: &lt;strong&gt;my deployment strategy for either on premise or cloud Laravel apps using containerization&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;IMPORTANT UPDATE&lt;/strong&gt;: I've PROMOTED this recipe to an installable composer package! Go check it out at &lt;br&gt;
&lt;a href="https://dev.to/jdsantos/how-i-deploy-laravel-apps-in-docker-with-just-two-commands-2cjl"&gt;How I deploy Laravel apps in Docker with just two commands&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;If you are on a hurry, you can find this on my github repo &lt;a href="https://github.com/jdsantos/laravel-alpine-nginx-phpfpm-opcache-docker" rel="noopener noreferrer"&gt;LANPOD - Laravel + Alpine + Nginx + PHP-FPM + OPCache + Docker&lt;/a&gt; and on your way there please  leave a star ⭐ on this repo! Thanks in advance!&lt;/p&gt;

&lt;h2&gt;
  
  
  🤯 but why? why when there are so many options?
&lt;/h2&gt;

&lt;p&gt;You're absolutely right. There are a lot of options out there with ready to use base images, &lt;strong&gt;lots and lots&lt;/strong&gt; of configurations out of the box, but at least to me all of them were a bit too much: either they packed a lot of stuff I didn't need, or they required lots of tunning to be able to run my apps accordingly to my clients requirements. Some of them were really heavy weight images 🥊, and extending them was also hard.&lt;/p&gt;

&lt;p&gt;That is why I prefered to build these small docker images, that pack the absolute minimum to run my Laravel apps, using the proven php-fpm on a base lightweight Alpine image, merged together with NGINX so that you can make the configuration an absolute breeze. I also packed supervisor and opcache that I usually use in my deployments.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxgsq1z43l6y9g1en63oh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxgsq1z43l6y9g1en63oh.png" alt="Tech stack"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  ☝️ first things first
&lt;/h2&gt;

&lt;p&gt;First of all, I started by inheriting from the base alpine php-fpm:8.3 base image and installed opcache + nginx + supervisor:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

FROM php:8.3-fpm-alpine

RUN apk --no-cache add \
    nginx \
    supervisor \
    &amp;amp;&amp;amp; docker-php-ext-enable opcache



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  🦸 supervisor: a single process to rule them all
&lt;/h2&gt;

&lt;p&gt;Then, as my apps usually need to process Laravel queues, I included supervisor to be able to run (and keep running at all times) the worker processes. Docker is really good at maintaining and restarting a single entrypoint process. However, if you launch sub processes within your app like supervisor, you must ensure it starts with things like &lt;code&gt;service start supervisor&lt;/code&gt;. Then it hit me: what if I used supervisor as my main docker process and entrypoint, and not only to run my queues? Then supervisor could handle and monitor all sub processes I need on my image on its own!&lt;/p&gt;

&lt;p&gt;I went for it, and in the end this is how my entrypoint exec command looks:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;


# Start supervisord
exec /usr/bin/supervisord -c /etc/supervisord.conf



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This instruction launches supervisor that spawns correctly these sub processes:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

[program:nginx]
command=/usr/sbin/nginx -g "daemon off;"

[program:php-fpm]
command=/usr/local/sbin/php-fpm

[program:crond]
command=/usr/sbin/crond -f

[program:queue-worker]
command=php /opt/laravel/artisan queue:work --sleep=3 --tries=3 --backoff=3 --max-time=3600



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  ✨ nginx: my frontend server of choice
&lt;/h2&gt;

&lt;p&gt;nginx is my choice in terms of serving content and handling incoming requests. The configuration is also very simple, and with these few lines, I got it working just fine:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;


        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass localhost:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        # Block httpoxy attacks. See https://httpoxy.org/.
        fastcgi_param HTTP_PROXY "";
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;

        # FastCGI buffering settings
        fastcgi_buffering on;
        fastcgi_buffers 16 32k;
        fastcgi_buffer_size 64k;
        fastcgi_busy_buffers_size 128k;
        fastcgi_temp_file_write_size 128k;



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  ⚡ php-fpm: a good php process manager
&lt;/h2&gt;

&lt;p&gt;As far as handling requests to my Laravel php backend, I prefer to use FastCGI Process Manager that manages PHP processes nicely. With just this configuration file, everything is looking good:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

[www]
listen = 9000
listen.allowed_clients = 127.0.0.1
user = www-data
group = www-data
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;Notice that although the 127.0.0.1 ip address seems harcoded, it works fine as the nginx + php-fpm run inside of the same container (no need for complicated networking here...)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  🔥 opcache: speedy requests
&lt;/h2&gt;

&lt;p&gt;In production environments you should use OPCache so that PHP doesn't need to load up and parse your PHP scripts on each request.&lt;/p&gt;

&lt;p&gt;Therefore, I configured my instance as follows:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

[opcache]

opcache.enable=${PHP_OPCACHE_ENABLE}
opcache.revalidate_freq=0
opcache.validate_timestamps=1
opcache.max_accelerated_files=10000
opcache.memory_consumption=192
opcache.max_wasted_percentage=10
opcache.interned_strings_buffer=16
opcache.fast_shutdown=1


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;You can find this on my github repo &lt;a href="https://github.com/jdsantos/laravel-alpine-nginx-phpfpm-opcache-docker" rel="noopener noreferrer"&gt;LANPOD - Laravel + Alpine + Nginx + PHP-FPM + OPCache + Docker&lt;/a&gt; and on your way there please  leave a star on this repo ⭐! Thanks in advance!&lt;/p&gt;

&lt;h2&gt;
  
  
  💻 Environment
&lt;/h2&gt;

&lt;p&gt;This was the environment that I used:&lt;/p&gt;

&lt;p&gt;Hardware&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Intel i7-8750H&lt;/li&gt;
&lt;li&gt;  24 GB of RAM&lt;/li&gt;
&lt;li&gt;  SSD 250GB&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Software&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Windows 11 Enterprise&lt;/li&gt;
&lt;li&gt;  Docker Desktop with WSL backend&lt;/li&gt;
&lt;li&gt;  Visual Studio Code&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hope this helped you in any way.&lt;/p&gt;

&lt;p&gt;See you soon! 👋&lt;/p&gt;

</description>
      <category>docker</category>
      <category>laravel</category>
      <category>nginx</category>
      <category>php</category>
    </item>
    <item>
      <title>Docker + Windows for Laravel Development: How I boosted performance with just this simple hack</title>
      <dc:creator>Jorge Santos</dc:creator>
      <pubDate>Mon, 18 Dec 2023 11:00:00 +0000</pubDate>
      <link>https://forem.com/jdsantos/docker-windows-for-laravel-development-how-i-boosted-performance-with-just-this-simple-hack-2998</link>
      <guid>https://forem.com/jdsantos/docker-windows-for-laravel-development-how-i-boosted-performance-with-just-this-simple-hack-2998</guid>
      <description>&lt;p&gt;Hi there! It's Jorge. In this post, I'm going to reveal a simple hack you can make on your docker-compose file if you're developing a Laravel project on a Windows machine with Docker, and experiencing &lt;strong&gt;really slow disk performance&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This was the docker-compose.yml file used in the development:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;version: "2.3"
services:
  app:
    build: ./app
    container_name: app
    environment:
      PHP_OPCACHE_ENABLE: 0
      PRODUCTION: 0
    ports:
      - "8080:80"
    depends_on:
      - "database"
      - "redis"
    volumes:
      - ./app:/app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice the volume &lt;code&gt;./app:/app&lt;/code&gt;. This volume allows us to bind our local directory &lt;code&gt;app&lt;/code&gt; to the container's /app directory so that when we change the code in the host machine, that code changes immediately on the container so that we can run and test our changes.&lt;/p&gt;

&lt;h2&gt;
  
  
  😈 vendor directory - the root of all evil
&lt;/h2&gt;

&lt;p&gt;When trying to figure out why the hell was this app so slow in local development environment vs the deployed production environment, I started to monitor my machine's resources at each step of the request. I noticed that serving static resources with nginx was always fast, but when the PHP backend kicked in, my SSD disk usage skyrocketed.&lt;/p&gt;

&lt;p&gt;I started to dig in the Laravel PHP backend, and noticed that even running a simple command like &lt;code&gt;composer dump-autoload&lt;/code&gt; was extremely slow; so my focus was now on optimizing this step alone. Again, started to notice that my container was heavily using my SSD just for the autoload generation. &lt;/p&gt;

&lt;p&gt;In my research on this problem, I bumped &lt;a href="https://code.visualstudio.com/remote/advancedcontainers/improve-performance"&gt;this post&lt;/a&gt; about how to improve performance on VS Code DevContainers (which I was already trying as well). This explanation by Microsoft said it all:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Since macOS and Windows run containers in a VM, "bind" mounts are not as fast as using the container's filesystem directly. Fortunately, Docker has the concept of a local "named volume" that can act like the container's filesystem but survives container rebuilds. This makes it ideal for storing package folders like node_modules, data folders, or output folders like build where write performance is critical.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I then changed my docker-compose.yml file to include a named volume specifically for the &lt;code&gt;/vendor&lt;/code&gt; directory but kept the original bind mount as well. After running &lt;code&gt;docker-compose up -d&lt;/code&gt; again, running &lt;code&gt;composer dump-autoload&lt;/code&gt; got really &lt;strong&gt;fast&lt;/strong&gt;! The problem was solved. 😌&lt;/p&gt;

&lt;p&gt;Here is what my final docker-compose.yml looked like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;version: "2.3"
services:
  app:
    build: ./app
    container_name: app
    environment:
      PHP_OPCACHE_ENABLE: 0
      PRODUCTION: 0
    ports:
      - "8080:80"
    depends_on:
      - "database"
      - "redis"
    volumes:
      - ./app:/app
# Add this vendor named volume for disk read/write performance boost
      - vendor-dir:/app/vendor
volumes:
# Don't forget to add it to the volumes section!
  vendor-dir:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  💻 Environment
&lt;/h2&gt;

&lt;p&gt;This was the development environment that I used for this legacy project:&lt;/p&gt;

&lt;p&gt;Hardware&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Intel i7-8750H&lt;/li&gt;
&lt;li&gt;24 GB of RAM&lt;/li&gt;
&lt;li&gt;SSD 250GB&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Software&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Windows 11 Enterprise&lt;/li&gt;
&lt;li&gt;Docker Desktop with WSL backend&lt;/li&gt;
&lt;li&gt;Visual Studio Code&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hope this helped you in any way.&lt;/p&gt;

&lt;p&gt;Hope to see you soon 👋&lt;/p&gt;

</description>
      <category>docker</category>
      <category>laravel</category>
      <category>performance</category>
      <category>windows</category>
    </item>
  </channel>
</rss>
