Sail is is a wrapper on top of docker compose. There are unofficial Docker environments for Laravel like Laradock but Sail is the official docker dev environment for Laravel. Dockerize for local dev environment with Laravel sailįirst, we will use Laravel Sail to run the application locally on our dev environment. I would like to thank him for his amazing work on this application. We will fork this application and dockerize it to run it on production not only on the dev environment. It is a relatively simple Laravel 8 application using MySQL as the database. The application is open source and he has a great tutorial explaining how the app was built. Example applicationįor this post as we want to dockerize an existing Laravel application, we will use the Student CRUD app built with Laravel by Digamber Rawat. Time to go deeper into dockerizing the Laravel app. To deploy the application you will need a Google cloud account.You are aware of how containers work and the need to build them and push them to a container registry.A general familiarity with how Laravel works will be needed.You have docker and docker-compose running on your machine.
Prerequisitesīefore we dive into the code and docker commands, it would be great to make sure of the following things: Next up we will park these terms and theory here and jump into running some commands in the command line to meet our goal of creating development and production-ready containers for an existing Laravel application. The open container initiative looks at the standardization and governance of container runtimes. Think of Docker as the AWS of the container world in terms of popularity, there is another container platform called rocket ( rkt) which can be considered something like Vultr in this analogy.
Therefore, Docker is a software that lets us build, package and run our applications as containers. So if containers enable us to ship the whole stack on each deployment after a successful build of course, where does this Docker thing come into play? Docker is an open-source platform (and a company Docker Inc) that enables software engineers to package applications into containers. To oversimplify things, you can think of containers as an improved virtual machine that is smaller, faster, and more resource-efficient. The benefits of using containers include small size, speed, efficiency, and portability. If you want to refer to the shipping containers analogy, be my guest. But without going to the details of virtualization and hypervisors the above way to understand them is simpler. There are multiple ways to define what containers and containerization are and how they operate. Another added bonus of this form of packaging is the specific version of the language and operating system can be specified in each build. Let’s get started What are containers?Ĭontainers simply put, are a way of packaging an application in a way that in addition to the application code and its dependencies the whole stack including the language, file system, and operating system can be shipped together. We will also deploy it to Google Cloud Run without getting into Kubernetes or any YAML configs.
In this step-by-step tutorial, we will dive into how to dockerize an existing Laravel app to run it on local and then make it ready to run on a production environment. In the past 5 years, both Docker and Laravel have exploded in popularity.