To create a simple Laravel development environment using Docker Compose, which runs
PHP-FPM
andNginx
, and offers high flexibility for customization to suit your project's specific needs.
laradock
, a Docker-based solution, offers a range of configuration options that allow you to easily extend and modify the default environment. By adjusting the provided scripts and configuration files, you can fine-tune the environment to meet the requirements of your application.
Here are several examples of how you can customize the default environment to better suit your needs:
- Choose any desired port for the application, enabling you to tailor the environment to your network setup.
- Select any
PHP
version from the official PHP image repository, giving you the flexibility to work with thePHP
version most suitable for your app. - Add additional packages such as
bash
,yarn
, or others to enhance the development environment with more tools that might be needed for your workflow. - Install custom
PHP
extensions or tools to meet the specific requirements of your application. - Modify
Nginx
configurations to adapt the web server's behavior to the specific needs of your Laravel app, such as adjusting rewrite rules or configuring SSL.
For more detailed guidance on how to customize the Docker setup, refer to the following documentation files:
- App Image:
compose/app/scripts/README.md
- Web Image:
compose/web/scripts/README.md
By referencing these resources, you can easily configure the development environment to match your precise needs, ensuring a streamlined and efficient Laravel development experience.
Important
New features will be added over time! Right now, it ONLY supports Linux, but Iβd love to expand it to macOS too. If youβre interested in helping it grow, your support could even help me save up for a MacBook π» to make that happen β but only if youβre definitely able to! π π
-
Clone this repository:
git clone git@github.com:fyvri/laradock.git && cd laradock
-
Make the script executable:
chmod +x ./laradock.sh
Before running laradock
, make sure that you have installed Docker
and are able to execute the docker compose
command in your terminal.
-
App Directories
All of your app directories should be placed under the
src/
directory. This directory contains the collection of your Laravel apps, which will be installed and managed vialaradock
. For comprehensive guidance on how to accomplish this, please refer to the detailed steps provided here. -
App Image
The
app
image serves as the core environment for running your Laravel application and is built upon thephp:${version}-fpm-alpine
image. By default, theapp
image will install the following packages:composer
curl
freetype-dev
libjpeg-turbo-dev
libzip-dev
Additionally, the
app
image will install severalPHP
extensions by default, including:bcmath
gd
mbstring
opcache
pdo_mysql
zip
However, you have the flexibility to customize the image by adding any extra packages or dependencies that your app requires. You can do this by creating custom scripts in the
compose/app/scripts/
directory. For detailed instructions on how to achieve this, please follow the steps outlined here. -
Web Image
The
web
image is based on thenginx:stable-alpine
image. It comes pre-configured to runNginx
and apply the necessary configurations for your app. However, if you need to add extra packages or replace the defaultNginx
configuration, you are free to modify it. To learn how to customize theweb
image, refer to the instructions provided here.
-
Basic
Simply,
laradock
can be run with:./laradock.sh compose
-
Advanced
./laradock.sh compose -n laradock -p 1337 -i laravel-10.x --php 8.1 --dev
This will display help for the tool. Here are all the options it supports.
π³ v0.0.1
______ ____________ ______
___ /_____ _____________ ______ /_____________ /__
__ /_ __ '/_ ___/ __ '/ __ / __ \ ___/_ //_/
_ / / /_/ /_ / / /_/ // /_/ // /_/ / /__ _ ,<
/_/ \__^_/ /_/ \__^_/ \__,_/ \____/\___/ /_/|_|
Usage:
./laradock.sh [command] [options...] <value> [--dev]
Commands:
compose : Compose π
help : Show this help message π
Options:
-n, --name : Set the image name
-p, --port : Set the app port (default: 8000)
-i, --input : Set the app directory name (e.g., awesome-laravel)
--php : Specify the PHP version (e.g., 5.6, 7.4, 8.1, etc)
--dev : Build image on development
Examples:
./laradock.sh compose
./laradock.sh compose -n laravel-5.8 -p 8000 -i laravel-5.8 --php 7.2
./laradock.sh compose -n laravel-9.x -p 8000 -i laravel-9.x --php 8.0 --dev
If you have any ideas, open an issue and tell me what you think.
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
Warning
If you have a suggestion that would make this better, please fork the repo and create a pull request. Don't forget to give the project a star π I can't stop saying thank you!
- Fork this project
- Create your feature branch (
git checkout -b feature/awesome-feature
) - Commit your changes (
git commit -m "feat: add awesome feature"
) - Push to the branch (
git push origin feature/awesome-feature
) - Open a pull request
This project is licensed under the MIT License. Feel free to use and modify it as needed.