How to setup Laravel Using Docker
Introduction:
Containers are a very popular method these days for deployment since you don’t really need to be aware of the underlying structure, Docker is the most popular way to containerize your application.
Laravel Docker:
There are some essential servers required to host your laravel application:
- Webserver: to server your web pages, the most two popular web servers are Apache and nginx.
- PHP: Laravel is built on PHP, the latest PHP version is 7.4
- Database: Laravel supports MySQL and Postgres SQL natively.
also, the below components are useful for supporting your application as well:
- redis: for cache and queue management.
- supervisor: for process management and monitoring.
- node: for build assets and managing frontend components
- composer: for managing PHP packages, its the official laravel package management tool.
Larapacket
Larapacket is an open-source GitHub repository that has a docker ready configuration to setup all the components mentioned above and getting your environment ready for laravel application.
Larapacket is a drop-in files for Laravel applications to start using Docker in development and production. These files include Docker files to build the necessary images, a compose file for development usage, and production deployment files via Docker swarm.
The docker
contains all Docker files and scripts to start using Docker with the application. The Docker setup depends on these official Docker images.
- ubuntu:18.04
- mysql:5.7
- redis:5.0.7
- node:13.2.0-alpine3.10
The compose file builds two images; The app image and node image. The app image is the main image for the application which contains Nginx, PHP-FPM, and Supervisor. The node image is used for front-end development. The two images are scoped under the repository name laravelapp.
Credit goes to Yazeed Obeid who made this happen and available for public use, don’t forget to star the repository and your feedback is welcome too.