{"id":17590,"date":"2024-07-12T06:00:00","date_gmt":"2024-07-12T06:00:00","guid":{"rendered":"https:\/\/www.directimpactsolutions.com\/?p=17590"},"modified":"2025-10-01T02:03:00","modified_gmt":"2025-10-01T02:03:00","slug":"laravel-deployments","status":"publish","type":"post","link":"https:\/\/www.directimpactsolutions.com\/en\/laravel-deployments\/","title":{"rendered":"Laravel Deployments"},"content":{"rendered":"<p>I\u2019d like to talk about Laravel deployments for both development and production environments. The default way to install a Laravel application for development now uses Docker technology, so I want to mention a thing or two about Docker, Laravel Sail, Spin, and the uses for each technology.<\/p><div class=\"wp-block-uagb-image uagb-block-2afa8357 wp-block-uagb-image--layout-default wp-block-uagb-image--effect-static wp-block-uagb-image--align-none\"><figure class=\"wp-block-uagb-image__figure\"><img decoding=\"async\" srcset=\"https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2024\/07\/Laravel-deployments-758x1024.png ,https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2024\/07\/Laravel-deployments.png 780w, https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2024\/07\/Laravel-deployments.png 360w\" sizes=\"auto, (max-width: 480px) 150px\" src=\"https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2024\/07\/Laravel-deployments-758x1024.png\" alt=\"laravel deployments\" class=\"uag-image-17591\" width=\"600\" height=\"1192\" title=\"Laravel-deployments\" loading=\"lazy\" role=\"img\"\/><\/figure><\/div><p><\/p><h2 class=\"wp-block-heading\">Docker Containers vs. Virtual Machines<\/h2><p>In older, more traditional virtual machines (VMs), configuration would look like that of a bare-bones server, with a fully featured operating system and all the necessary software for the tech stack installed on top of that.<\/p><p>Docker containers are typically more lightweight. Each Docker container uses the <a href=\"https:\/\/simple.wikipedia.org\/wiki\/Kernel_(computer_science)\" target=\"_blank\" rel=\"noreferrer noopener\">kernel<\/a> of the host\u2019s operating system instead of having its own. Furthermore, each container is typically broken down into the smallest possible component.<\/p><p>Despite the fact that Docker containers make use of the host machine\u2019s kernel, they have no knowledge of the host machine, and thus operate in isolation. This can be a huge benefit for security.<\/p><h3 class=\"wp-block-heading has-ast-global-color-2-color has-text-color has-link-color wp-elements-829f00fb7c22346802b7d64cdc78ca69\">What is Docker Compose?<\/h3><p>Knowing that Docker containers are typically broken down into small, bite-sized pieces, it follows that with larger or complicated applications, we might need multiple. In those cases, will need to be able to orchestrate them together harmoniously; that\u2019s where Docker Compose comes in. Docker Compose offers a clever configuration file structure that the engineer can use to define all the parts and how they will work together.<\/p><p>For example, I could define a Docker Compose configuration file that would specify that both a database server and a web server are needed, and that the web server depends upon the database server being available.<\/p><p>Once configuration for Docker Compose has been defined, setting up your environment is typically just a single command away. Teardown is just as simple.<\/p><h3 class=\"wp-block-heading has-ast-global-color-2-color has-text-color has-link-color wp-elements-b5d4600fbf0305b6d86776ee69188749\">Benefits<\/h3><p>We\u2019ve been using Docker technology to standardize our development environment for some time now; this has made a tremendous difference in several ways.<\/p><p>Each of our developers&#8217; own local environments are now exactly the same, which eliminates the \u201cIt works on my machine\u201d problem. This is true even with developers using all the main Operating Systems <em>(Windows\/Mac\/Linux)<\/em>. Developer machine deployments are now swift and efficient, as they\u2019re all standardized, and deployed in a standardized fashion, typically with a single command.<\/p><p>Another great thing about working with Docker containers is that all the software needed for a project is typically contained within the containers, making it very easy to switch between projects without worrying about conflicting software configurations. Also, Docker Compose is self-documenting in a way; by keeping its configuration within our repositories, it\u2019s quite simple for us to determine which version of PHP a system was designed around (as an example).<\/p><h2 class=\"wp-block-heading\">Laravel + Docker = Sail<\/h2><p>Here at Direct Impact Solutions, we\u2019ve used the <a href=\"https:\/\/laravel.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">Laravel PHP Framework<\/a> for a significant number of systems. The good folks who created the Laravel framework have even adopted usage of Docker as their default installation method using their own Docker Compose system, <a href=\"https:\/\/laravel.com\/docs\/sail\" target=\"_blank\" rel=\"noreferrer noopener\">Laravel Sail<\/a>. Laravel Sail is customizable and easy to use, so we\u2019ve made use of it within some of our projects. I like how easy it is to add new service containers into a project. For instance, once you get to a spot in your development where your application needs to send emails, you can quickly add a container for <code>mailpit<\/code> using baked-in commands.<\/p><h3 class=\"wp-block-heading has-ast-global-color-2-color has-text-color has-link-color wp-elements-1816880039ee651d0a059c47d6fda042\">Laravel Sail Wishlist<\/h3><p>One unfortunate thing about Laravel Sail, however, is the fact that it does not make use of a traditional web server, but rather an artisan command (<code>artisan serve<\/code>) that acts as a wrapper around <a href=\"https:\/\/www.php.net\/manual\/en\/features.commandline.webserver.php\" target=\"_blank\" rel=\"noreferrer noopener\">PHP\u2019s built-in web server<\/a>. This is unfortunate because PHP\u2019s built-in web server runs only one single-threaded process. As such, it\u2019s not designed to handle multiple requests and should not be used for production environments.<\/p><p>Since Laravel Sail is built using Docker compose technology, it should (in theory) be possible to make it work using a traditional web server so that we would not have the limitations that prevent us from using this tech in production. Unfortunately, I suspect that this won\u2019t be happening any time soon. This may have something to do with the fact that the developers of Laravel and Laravel Sail also have a production deployment and management product known as <a href=\"https:\/\/forge.laravel.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">Laravel Forge<\/a>.<\/p><h3 class=\"wp-block-heading has-ast-global-color-2-color has-text-color has-link-color wp-elements-d9beafd37d636e82d68f81479e11217a\">Where To From Here?<\/h3><p>Due to our appreciation for standardization, simplicity, and Docker\/Sail, we are looking into other technologies in hopes of finding something that offers the continuity we want between dev and production environments.<\/p><h2 class=\"wp-block-heading\">Spin<\/h2><p>ServerSideUP has recently published an open-source development tool, <a href=\"https:\/\/serversideup.net\/open-source\/spin\/\" target=\"_blank\" rel=\"noreferrer noopener\">Spin<\/a>, that\u2019s very similar to Laravel Sail. Spin aims to do exactly what we originally wanted from Laravel Sail, and then some! Not only does it allow us to reuse the same dev environment within production, but also it does more.<\/p><h3 class=\"wp-block-heading has-ast-global-color-2-color has-text-color has-link-color wp-elements-1bc3f94b7e0028dda8a9c70143db3f59\">Spin Usage<\/h3><p>In order to begin using Laravel Sail, the engineer would often run <code>sail up -d<\/code> from the command line.<br>Similarly, when using Spin instead of Sail, one can execute <code>spin up -d<\/code> to create an environment. Similar commands are provided for running commands inside of the Docker containers as well (it\u2019s common to run <code>PHP artisan<\/code> commands from the <code>PHP<\/code> container, and <code>npm run<\/code> commands from the <code>node<\/code> container).<\/p><h3 class=\"wp-block-heading has-ast-global-color-2-color has-text-color has-link-color wp-elements-f17370877ca5ed398dc21110890bd29f\">Spin Update Checks<\/h3><p>Spin checks for updates when you run the <code>spin up<\/code> command. That\u2019s refreshing to see, and not something I\u2019ve seen in Laravel Sail.<\/p><h3 class=\"wp-block-heading has-ast-global-color-2-color has-text-color has-link-color wp-elements-ec3e2e09d5b55b29dd39d65dd2882289\">Spin Environment Discrepancies<\/h3><p>In theory, using Spin for both dev and production deployments should always yield identical environments for end users. Separate <code>Docker-compose.yml<\/code> files are provided for both, however, so for those instances where some things need to change between environments (example <code>mailpit<\/code> in dev, proper mail server in production), Spin has you covered. There are <code>Docker-compose.yml<\/code> files provided for dev, production, and even continuous integration (CI).<\/p><h3 class=\"wp-block-heading has-ast-global-color-2-color has-text-color has-link-color wp-elements-c94984cd8ff6426cb59b36d05371fc75\">Spin Configuration<\/h3><p>A project that has Spin integrated will come with other configuration files beyond the simple Docker Compose configuration files. These additional configuration files let the engineer define details about SSH connections and the user accounts that will be responsible for deploying the solution. When being deployed to a production environment, Docker Swarm technology is used. There\u2019s even a <code>.spin-inventory.ini<\/code> file in <a href=\"https:\/\/docs.ansible.com\/ansible\/latest\/inventory_guide\/intro_inventory.html\" target=\"_blank\" rel=\"noreferrer noopener\">Ansible inventory format<\/a> where you can define the servers to be used.<\/p><h3 class=\"wp-block-heading has-ast-global-color-2-color has-text-color has-link-color wp-elements-f4be241225f5095dcb5878e0cfd3cdbf\">Spin Encryption<\/h3><p>Since Spin utilizes a number of configuration files that could potentially hold sensitive information, it\u2019s important to note that Spin highly encourages encryption of these files. Once encrypted, you can confidently commit and store these files within your repository. Spin comes equipped with its own <a href=\"https:\/\/serversideup.net\/open-source\/spin\/docs\/command-reference\/vault\" target=\"_blank\" rel=\"noreferrer noopener\">vault<\/a> which contains commands for encrypting, decrypting, editing, etc.<\/p><h3 class=\"wp-block-heading has-ast-global-color-2-color has-text-color has-link-color wp-elements-3f654b92c5d49f5bac24598bfc26124a\">Zero-Downtime Deployments<\/h3><p>Spin helps engineers by providing GitHub action templates and <a href=\"https:\/\/serversideup.net\/open-source\/spin\/docs\/guide\/zero-downtime-deployments-with-github-actions\" target=\"_blank\" rel=\"noreferrer noopener\">supporting documentation<\/a>. New Laravel projects can be started with Spin. Alternatively, you can add Spin to an existing Laravel project.<\/p><p>Regardless of the approach you take, you\u2019ll be given access to templated GitHub actions. The de facto action is to deploy to production whenever a new release is added to GitHub. Getting this up and running requires a few other pieces, but Spin guides you through this process.<\/p><h3 class=\"wp-block-heading has-ast-global-color-2-color has-text-color has-link-color wp-elements-c441e47fc192cb56c9ced515e20b684a\">Conclusion<\/h3><p>Spin is similar to Laravel Sail, utilizes tried-and-true technologies like Docker and Ansible, has you covered on security and flexibility, and even eliminates the issue of having different production and development environments (which is why most of us started using Docker in the first place). Spin also helps with zero-downtime deployments, making this a very promising tool in our tool belts.<\/p>","protected":false},"excerpt":{"rendered":"<p>I\u2019d like to talk about Laravel deployments for both development and production environments. The default way to install a Laravel application for development now uses Docker technology, so I want to mention a thing or two about Docker, Laravel Sail, Spin, and the uses for each technology. Docker Containers vs. Virtual Machines In older, more &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"https:\/\/www.directimpactsolutions.com\/en\/laravel-deployments\/\"> <span class=\"screen-reader-text\">Laravel Deployments<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":7,"featured_media":17668,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","footnotes":""},"categories":[32],"tags":[],"class_list":["post-17590","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-web-applications"],"uagb_featured_image_src":{"full":["https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2024\/07\/iStock-2123149472-1.jpg",926,576,false],"thumbnail":["https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2024\/07\/iStock-2123149472-1-150x150.jpg",150,150,true],"medium":["https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2024\/07\/iStock-2123149472-1-300x187.jpg",300,187,true],"medium_large":["https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2024\/07\/iStock-2123149472-1-768x478.jpg",768,478,true],"large":["https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2024\/07\/iStock-2123149472-1.jpg",926,576,false],"1536x1536":["https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2024\/07\/iStock-2123149472-1.jpg",926,576,false],"2048x2048":["https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2024\/07\/iStock-2123149472-1.jpg",926,576,false],"woocommerce_thumbnail":["https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2024\/07\/iStock-2123149472-1-300x300.jpg",300,300,true],"woocommerce_single":["https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2024\/07\/iStock-2123149472-1-600x373.jpg",600,373,true],"woocommerce_gallery_thumbnail":["https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2024\/07\/iStock-2123149472-1-100x100.jpg",100,100,true]},"uagb_author_info":{"display_name":"Matt Leering","author_link":"https:\/\/www.directimpactsolutions.com\/en\/author\/matt-leering\/"},"uagb_comment_info":0,"uagb_excerpt":"I\u2019d like to talk about Laravel deployments for both development and production environments. The default way to install a Laravel application for development now uses Docker technology, so I want to mention a thing or two about Docker, Laravel Sail, Spin, and the uses for each technology. Docker Containers vs. Virtual Machines In older, more&hellip;","_links":{"self":[{"href":"https:\/\/www.directimpactsolutions.com\/en\/wp-json\/wp\/v2\/posts\/17590","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.directimpactsolutions.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.directimpactsolutions.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.directimpactsolutions.com\/en\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.directimpactsolutions.com\/en\/wp-json\/wp\/v2\/comments?post=17590"}],"version-history":[{"count":4,"href":"https:\/\/www.directimpactsolutions.com\/en\/wp-json\/wp\/v2\/posts\/17590\/revisions"}],"predecessor-version":[{"id":20712,"href":"https:\/\/www.directimpactsolutions.com\/en\/wp-json\/wp\/v2\/posts\/17590\/revisions\/20712"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.directimpactsolutions.com\/en\/wp-json\/wp\/v2\/media\/17668"}],"wp:attachment":[{"href":"https:\/\/www.directimpactsolutions.com\/en\/wp-json\/wp\/v2\/media?parent=17590"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.directimpactsolutions.com\/en\/wp-json\/wp\/v2\/categories?post=17590"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.directimpactsolutions.com\/en\/wp-json\/wp\/v2\/tags?post=17590"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}