Docker Compose template for rapid Laravel/PHP development.
Linux, OS X and Windows friendly.
This Docker template is also suitable for any other PHP projects, feel free to modify Docker configuration as needed.
- Nginx
- PHP 8.1.0
- MySQL
- Redis
- Adminer
- Redis Commander
- Mailhog (Mailcatcher alternative)
- Clone this repo:
git clone git@github.com:maxkostinevich/Laravel-Docker-Template.git yourproject
cd yourproject
rm -rf .git
To delete sample index.php
file run rm -rf /src/public
-
Update project name in
.env
file -
Build and run containers:
docker-compose build
docker-compose up
- Put your project files into
/src
folder and update your project.env
file:
APP_URL: http://localhost:8080
DB_HOST: mysql
DB_PORT: 3306
Note: webroot folder is set to /src/public
- Login into
php-fpm
container:
- on Windows:
php.bat
- on Linux/OS X:
sh php.sh
and run all required commands, for example:
composer install
php artisan migrate
npm install
npm run dev
If your APP_KEY
is not generated yet, you may generate it by the following command:
php artisan key:generate
To create new Laravel project simply login into php-fpm
container using the following script:
- on Windows:
php.bat
- on Linux/OS X:
sh php.sh
and create a new Laravel app using laravel new
command.
You may also run containers in the background using the following script:
- on Windows:
serve.bat
- on Linux/OS X:
sh serve.sh
To stop Docker containers run:
docker-compose stop
To delete Docker containers run:
docker-compose down
For your convenience, Adminer is installed and available at http://localhost:6080
You may also login into mysql
container using the following script:
- on Windows:
mysql.bat
- on Linux/OSX:
sh mysql.sh
To use Redis in your project,you'd need to install predis first:
composer require predis/predis
Then setup Redis connection in your .env
file as follows:
REDIS_HOST=redis
CACHE_DRIVER=redis
SESSION_DRIVER=redis
QUEUE_DRIVER=redis
For your convenience, Redis Commander is installed and available at http://localhost:6081
Phantom containers
In order to force stop all running containers you may need to run the following script:
docker-stop.bat
Make shorthand command
make.bat appname
- App URL:
http://localhost:8080
- Adminer:
http://localhost:6080
- Redis Commander:
http://localhost:6081
- MailHog:
http://localhost:6082
(c) 2022 Max Kostinevich - All rights reserved.