easy to set up, robust and production ready environment for Laravel using Docker, Docker Compose and bash script.
currently these scripts are debian based and tested on ubuntu 22.04.3 live Server
EZ Docker For Laravel provides an easy-to-use, production-ready environment for running Laravel applications using Docker and Docker Compose. It simplifies the deployment process by offering a set of scripts to manage configurations, deploy, and maintain Laravel projects efficiently across various environments, such as test, staging, and production. The software streamlines server setup and management, offering features like support for Nginx, MySQL, and PHP-FPM, as well as additional services and extensions tailored to Laravel's requirements. By following the steps outlined in this readme, you can quickly set up your Laravel project and deploy it for reliable and scalable hosting.
Currently, the scripts are successfully working in test and staging environments, and I plan to deploy them in production soon.
- Clone the repository using the following command:
sudo git clone https://github.com/MansourM/ez-docker-for-laravel.git && cd ez-docker-for-laravel
- install docker engine (Optional, only if not installed already)
sudo ./ez docker install
-
Initialize your Laravel app
sudo ./ez laravel new
-
deploy your shared containers (Nginx, Mysql, PhpMyAdmin)
sudo ./ez shared deploy
-
deploy your laravel project
sudo ./ez laravel deploy {app_name} {environment}
- now your website is running at
<your_ip_address>:<APP_PORT>
- website is only exposed via
APP_PORT
indev
andtest
environments to access thestaging
orproduction
website you need to configure them on your domain using npm proxy manager
You can find examples of GitHub Actions in the .github.example/workflows
folder. Remember to remove the .example
from the folder name before using the workflows.
Nginx Proxymanager default login information:
Username | Password |
---|---|
[email protected] | changeme |
Command | Description |
---|---|
sudo ./ez --help |
Shows all commands |
sudo ./ez docker install |
Adds the Docker repository to APT sources and then installs the Docker engine. |
sudo ./ez docker uninstall |
Uninstalls the Docker engine. |
sudo ./ez docker remove |
Removes all images, containers, and volumes. (You have to delete any edited configuration files manually.) |
sudo ./ez shared deploy |
Builds and runs shared service containers (Nginx, MySQL, phpMyAdmin, Portainer). |
sudo ./ez shared start |
Starts shared service containers. |
sudo ./ez shared stop |
Stops shared service containers. |
sudo ./ez shared restart |
Restarts shared service containers. |
sudo ./ez shared down |
Removes shared service containers. |
sudo ./ez laravel deploy <app_name> <app_env> |
Clones your Laravel repository, builds its assets, configures it for production, and then starts it. |
sudo ./ez laravel start <app_name> <app_env> |
Starts Laravel container. |
sudo ./ez laravel stop <app_name> <app_env> |
Stops Laravel container. |
sudo ./ez laravel restart <app_name> <app_env> |
Restarts Laravel container. |
sudo ./ez laravel down <app_name> <app_env> |
Removes Laravel container. |
I have installed the minimum PHP plugins required to run Laravel (marked by ✔) in the container. You should add others based on your project's needs. Add them in laravel.Dockerfile
.
Name | Explanation | |
---|---|---|
✔ | php8.2-cli | Command-line interface for PHP. |
✔ | php8.2-curl | cURL library support for PHP. |
✔ | php8.2-mysql | MySQL database support for PHP. |
✔ | php8.2-mbstring | Multibyte string support for PHP. |
✔ | php8.2-xml | XML support for PHP. |
✗ | php8.2-imap | IMAP support for PHP. |
✗ | php8.2-dev | Development files for PHP. |
✗ | php8.2-pgsql | PostgreSQL database support for PHP. |
✗ | php8.2-sqlite3 | SQLite3 database support for PHP. |
✗ | php8.2-gd | GD library support for PHP. |
✗ | php8.2-zip | ZIP archive support for PHP. |
✗ | php8.2-bcmath | BCMath arbitrary precision mathematics support for PHP. |
✗ | php8.2-soap | SOAP support for PHP. |
✗ | php8.2-intl | Internationalization support for PHP. |
✗ | php8.2-readline | Readline library support for PHP. |
✗ | php8.2-ldap | LDAP support for PHP. |
✗ | php8.2-msgpack | MessagePack support for PHP. |
✗ | php8.2-igbinary | Igbinary support for PHP. |
✗ | php8.2-redis | Redis support for PHP. |
✗ | php8.2-swoole | Swoole extension for PHP. |
✗ | php8.2-memcached | Memcached support for PHP. |
✗ | php8.2-pcov | Code coverage driver for PHP. |
✗ | php8.2-xdebug | Xdebug support for PHP. |
✗ | php8.2-imagick | ImageMagick extension for PHP. |
- say hi!
- add flag to use default input instead of prompting the user
- changing GIT_URL in app.env has no effect, will still pull from previous repo
- make builder stage on volume so we have better caching on it?
- add text log files
- mayne merge docker and shared folder? needs better naming or refactor -probably
- review https://laradock.io/getting-started/
- review https://github.com/masoudfesahat/laravel-with-docker
- APP_ENV in laravel.dockerfile is affecting build cache when building different env after each other ----> or not!!!?
- be more strict on showing passwords in cli? (it is good for convenience though!)
- add flags like -d on laravel new to go with the default instead of prompting the user, etc
- image/build cache seems to be effected when service/container name is changed -> research this
- add docker to sudoers
- add tags to --build then remove orphans
- better handling of unused/dangling/orphan images/containers
- explain how to change scripts and generate new a
ez
script with Bashly - mark project as production ready when 1 month of testing in production is done.
- Implement a GUI (optional dashboard).
- Add more (modular) services (e.g., Redis, Memcached).
- Integrate a DNS service.
- add local source (currently only git is supported)
- having # in DB_PASSWORD will break the script (everything will run but you cant access db as password won't be set properly)
Contributions are always welcome! Feel free to fork the project and submit a pull request.
This project is licensed under the GNU GPL V2 License.
Seyed Mansour Mirbehbahani - [email protected]
- Awesome Readme Template
- M.Mahdi Mahmoodian Help/Review Nginx/FPM setup
- nginx-php-fpm nginx/fpm configuration and dockerfile