Hi there! It's Jorge. It's been a while since my last post, and this one might sound the same as one that you might have read around here. But come along and I promise you that you never again will have to build docker images from scratch to your Laravel projects!
⚡TL;DR
Tired of configuring Docker from scratch for every Laravel project? This is the link to the Github repository for the Laradocker project, a brand new composer package that sets up your Laravel project with Docker with just these two simple commands:
# Run these commands inside your Laravel project: composer require --dev jdsantos/laradocker php artisan laradocker:install # That's it! Follow the instructions and you are done!
On your way there, please leave a star ⭐ on the repo to show your support.
Thanks in advance ❤️
?The backstory
In my previous post, I brought you LANPOD 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 laravel + alpine linux + nginx + php-fpm + opcache + docker you absolutely loved.
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 Docker or Podman. 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.
All good, but...
?The pain
Something was off.
While LANPOD as a template repository on Github was a helpful starting point for a brand new Laravel app, and a LOT 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 MANUALLY 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.
?The solution
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?
"That's it! I'm going to create a Laravel package that I can install in my projects! Let's do this!"
So, the adventure began!
I started to scaffold my brand new composer project with all required dependencies to develop and test Laravel packages including orchestra/testbench, laravel/pint and larastan/larastan.
After that, I set up right from the start a Github repository for the project, auto-publish capabilities to Packagist, the PHP composer package repository, and spawned Github actions for a super simple CI/CD pipeline to run my tests at each push.
With all this in place, the rest was peanuts: I used all of LANPOD's files as mere stubs for this project, and used the plain Artisan Console to develop a pretty silly and basic UI for installing this recipe:
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!
All files get generated in an instant and copied into your project!
??The code
This package is completely free & open-source and you can find the source code here!. On your way there, please leave a star ⭐ on the repo to show your support.
Thanks in advance ❤️
? Environment
This was the environment that I used:
Hardware
- Intel i7-8750H
- 24 GB of RAM
- SSD 250GB
Software
- Windows 11 Enterprise
- Docker Desktop with WSL backend
- Visual Studio Code
Hope this helped you in any way.
See you soon! ?
The above is the detailed content of How I deploy Laravel apps in Docker with just two commands. For more information, please follow other related articles on the PHP Chinese website!

Long URLs, often cluttered with keywords and tracking parameters, can deter visitors. A URL shortening script offers a solution, creating concise links ideal for social media and other platforms. These scripts are valuable for individual websites a

Following its high-profile acquisition by Facebook in 2012, Instagram adopted two sets of APIs for third-party use. These are the Instagram Graph API and the Instagram Basic Display API.As a developer building an app that requires information from a

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

This is the second and final part of the series on building a React application with a Laravel back-end. In the first part of the series, we created a RESTful API using Laravel for a basic product-listing application. In this tutorial, we will be dev

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

The 2025 PHP Landscape Survey investigates current PHP development trends. It explores framework usage, deployment methods, and challenges, aiming to provide insights for developers and businesses. The survey anticipates growth in modern PHP versio


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

SublimeText3 Mac version
God-level code editing software (SublimeText3)

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver CS6
Visual web development tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software
