To create a simple Laravel development environment using
Docker Compose
, which runsPHP-FPM
andNginx
, and offers high flexibility for customization to suit your project's specific needs.
laradock
is a Docker Compose-based solution that allows you to run Laravel applications using PHP-FPM
and Nginx
. It is designed to be highly flexible, enabling you to customize the environment to meet the unique needs of your project. Whether you need to adjust ports, select specific PHP versions, or add additional tools and services, laradock
makes it easy to create a development environment that works seamlessly for you.
Key Features
- Customizable Ports: You can configure any port for your application to fit your network setup, ensuring compatibility with your existing infrastructure.
- Flexible PHP Versions: Choose from a wide range of PHP versions available in the official PHP image repository, allowing you to match the exact version required by your project.
- Extendable Environment: Easily add additional packages such as
bash
,yarn
, or custom PHP extensions to tailor the environment to your needs. - Nginx Customization: Modify Nginx configurations to suit your Laravel application, including SSL settings, rewrite rules, and other customizations.
- Customize Services: Add any additional services like
MySQL
,Redis
, or any other dependencies your project may require.
For detailed instructions on how to customize your environment, refer to the following documentation:
- App Image:
src/app/scripts/README.md
- Web Image:
src/web/scripts/README.md
- Custom Services:
src/custom/README.md
By following 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! Currently, 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 the Repository:
git clone [email protected]:fyvri/laradock.git
-
Add
laradock
to Your$PATH
:sudo ln -s $(pwd)/laradock/bin/laradock.sh /usr/local/bin/laradock
-
Verify the Installation:
which laradock
This should output the location where laradock is installed (e.g., /usr/local/bin/laradock).
Note
Ensure you have Docker
installed and can run the docker compose
command before proceeding.
-
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 several PHP 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
src/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 default Nginx configuration, you are free to modify it. To learn how to customize theweb
image, refer to the instructions provided here. -
Custom Services
laradock
allows you to design and customize your environment to include any services your project may require, such asMySQL
,Redis
, or any other dependencies. The system is pre-configured to automatically detect and process Docker Compose files that follow a specific naming convention, requiring these files to end with the.docker-compose.yml
extension. For a step-by-step guide on how to customize your environment and configure these services, refer to the detailed documentation here.
-
Initialize:
Navigate to your project directory and run the following command to initialize:
laradock init
This command will prompt you for the project name, port, and PHP version. The Docker Compose settings will be saved in the
.laradock
directory. -
Build and Start Services:
laradock compose
For more commands and options, run
laradock --help
.
This will display help for the tool. Here are all the full list of available commands and options it supports.
$ laradock --help
______ ____________ π³ ______
___ /_____ _____________ ______ /_____________ /__
__ /_ __ '/_ ___/ __ '/ __ / __ \ ___/_ //_/
_ / / /_/ /_ / / /_/ // /_/ // /_/ / /__ _ ,<
/_/ \__^_/ /_/ \__^_/ \__,_/ \____/\___/ /_/|_|
Usage: laradock [OPTIONS] COMMAND
Define and run multi-container applications with laradock
Options:
--all-resources Include all resources, even those not used by services
--ansi string Control when to print ANSI control characters ("never"|"always"|"auto") (default "auto")
--compatibility Run compose in backward compatibility mode
--dry-run Execute command in dry run mode
--env-file stringArray Specify an alternate environment file
--parallel int Control max parallelism, -1 for unlimited (default -1)
--profile stringArray Specify a profile to enable
--progress string Set type of progress output (auto, tty, plain, json, quiet) (default "auto")
-p, --project-name string Project name
Commands:
artisan Execute artisan commands
clean Stop and remove all projects (images, containers, volumes and networks)
composer Execute composer commands
compose Build images and run containers in the background
container Manage containers
image Manage images
init Initialize laradock setup or reinitialize an existing one
network Manage networks
reboot Restart all services
shutdown Stop all services
startup Start all services
volume Manage volumes
Additional Commands:
attach Attach local standard input, output, and error streams to a service's running container
build Build or rebuild services
commit Create a new image from a service container's changes
config Parse, resolve and render compose file in canonical format
cp Copy files/folders between a service container and the local filesystem
create Creates containers for a service
down Stop and remove containers, networks
events Receive real time events from containers
exec Execute a command in a running container
export Export a service container's filesystem as a tar archive
images List images used by the created containers
kill Force stop service containers
logs View output from containers
ls List running compose projects
pause Pause services
port Print the public port for a port binding
ps List containers
pull Pull service images
push Push service images
restart Restart service containers
rm Removes stopped service containers
run Run a one-off command on a service
scale Scale services
start Start services
stats Display a live stream of container(s) resource usage statistics
stop Stop services
top Display the running processes
unpause Unpause services
up Create and start containers
version Show the Docker Compose version information
wait Block until containers of all (or specified) services stop.
watch Watch build context for service and rebuild/refresh containers when files are updated
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 GNU GPLv3 License. You are free to use, modify, and distribute it in accordance with the terms of this license.