Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maxkostinevich/laravel-docker-template
Docker compose template for Laravel application
https://github.com/maxkostinevich/laravel-docker-template
docker docker-compose docker-compose-template docker-laravel laravel php
Last synced: about 1 month ago
JSON representation
Docker compose template for Laravel application
- Host: GitHub
- URL: https://github.com/maxkostinevich/laravel-docker-template
- Owner: maxkostinevich
- License: mit
- Created: 2019-04-12T10:06:56.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-09-07T11:16:00.000Z (over 2 years ago)
- Last Synced: 2023-02-27T12:27:28.124Z (almost 2 years ago)
- Topics: docker, docker-compose, docker-compose-template, docker-laravel, laravel, php
- Language: Batchfile
- Homepage: https://www.youtube.com/watch?v=DNyQX00X_cg
- Size: 23.4 KB
- Stars: 34
- Watchers: 4
- Forks: 17
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Laravel Docker Template
Docker Compose template for rapid Laravel/PHP development.![bash](https://user-images.githubusercontent.com/10295466/56030094-b0ec6900-5d24-11e9-967f-259a9579dd70.png)
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.
## Included services
- Nginx
- PHP 8.1.0
- MySQL
- Redis
- Adminer
- Redis Commander
- Mailhog (Mailcatcher alternative)## Project Setup
### Prepare the Docker template
1. Clone this repo:
```
git clone [email protected]:maxkostinevich/Laravel-Docker-Template.git yourproject
cd yourproject
rm -rf .git
```To delete sample ```index.php``` file run ```rm -rf /src/public```
2. Update project name in ```.env``` file
3. Build and run containers:
```
docker-compose build
docker-compose up
```### Setting up existing project
1. 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```
2. 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 migratenpm install
npm run dev
```If your ```APP_KEY``` is not generated yet, you may generate it by the following command:
```
php artisan key:generate
```### Setting up new project
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.
### Running containers in the background
You may also run containers in the background using the following script:
- on Windows:
```
serve.bat
```- on Linux/OS X:
```
sh serve.sh
```### Stop and delete containers
To stop Docker containers run:
```
docker-compose stop
```To delete Docker containers run:
```
docker-compose down
```### Database Management
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
```### Redis configuration
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=redisCACHE_DRIVER=redis
SESSION_DRIVER=redis
QUEUE_DRIVER=redis
```For your convenience, Redis Commander is installed and available at ```http://localhost:6081```
### Windows-only
**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
```### Main Endpoints
- App URL: ```http://localhost:8080```
- Adminer: ```http://localhost:6080```
- Redis Commander: ```http://localhost:6081```
- MailHog: ```http://localhost:6082```---
### [MIT License](https://opensource.org/licenses/MIT)
(c) 2022 [Max Kostinevich](https://maxkostinevich.com) - All rights reserved.