Skip to content

easy to setup, robust and production ready environment for Laravel using Docker, Docker Compose and bash script.

License

Notifications You must be signed in to change notification settings

MansourM/ez-docker-for-laravel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EZ Docker For Laravel

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

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.

🧰 Getting Started

  1. 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
  1. Initialize your Laravel app

    sudo ./ez laravel new
  2. deploy your shared containers (Nginx, Mysql, PhpMyAdmin)

    sudo ./ez shared deploy
    
  3. 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 in dev and test environments to access the staging or production website you need to configure them on your domain using npm proxy manager

⚙️ Github actions

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.

💡 Additional Info

Nginx Proxymanager default login information:

Username Password
[email protected] changeme

👀 Other Commands

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.

➕ PHP Extensions

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.

🧭 TODOs

  • 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.

🧭 Maybe?

  • 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)

⚠️ Known Issues

  • having # in DB_PASSWORD will break the script (everything will run but you cant access db as password won't be set properly)

👋 Contributing

Contributions are always welcome! Feel free to fork the project and submit a pull request.

⚠️ License

This project is licensed under the GNU GPL V2 License.

🤝 Contact

Seyed Mansour Mirbehbahani - [email protected]

💎 Acknowledgements

About

easy to setup, robust and production ready environment for Laravel using Docker, Docker Compose and bash script.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published