All Projects → maxkostinevich → Laravel-Docker-Template

maxkostinevich / Laravel-Docker-Template

Licence: MIT license
Docker compose template for Laravel application

Programming Languages

Batchfile
5799 projects
Dockerfile
14818 projects
shell
77523 projects
PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to Laravel-Docker-Template

Laradock
Full PHP development environment for Docker.
Stars: ✭ 11,064 (+35590.32%)
Mutual labels:  docker-compose-template, docker-laravel
docker-laravel-api-dev
🐳 The containerized Laravel API development environment
Stars: ✭ 31 (+0%)
Mutual labels:  docker-laravel
Harbor
Command-line tool to dockerize Laravel.
Stars: ✭ 51 (+64.52%)
Mutual labels:  docker-compose-template
The-Overly-Complicated-Random-Number-Generator
An Overly Complex Random Number Generator, created to demystify how containers work.
Stars: ✭ 25 (-19.35%)
Mutual labels:  docker-compose-template
docker-compose-laravel
A Docker Compose setup for Laravel projects.
Stars: ✭ 23 (-25.81%)
Mutual labels:  docker-compose-template
ansible-role-containerized-wordpress
Deploy & run Docker Compose project for WordPress instance with Let's Encrypt HTTPS encryption
Stars: ✭ 15 (-51.61%)
Mutual labels:  docker-compose-template
cakephp-docker
A cakephp/app 4.2 template for Docker and Kubernetes.
Stars: ✭ 17 (-45.16%)
Mutual labels:  docker-compose-template
yii2-laradock
Laradock pre-configured for Yii2 Framework (https://github.com/LaraDock/laradock)
Stars: ✭ 16 (-48.39%)
Mutual labels:  docker-compose-template
docker-laravel-appengine
Laravel dockerized with official Google App Engine flexible php environment + swoole.
Stars: ✭ 66 (+112.9%)
Mutual labels:  docker-laravel

Laravel Docker Template

Docker Compose template for rapid Laravel/PHP development.

bash

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

  1. Update project name in .env file

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

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

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=redis

CACHE_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

(c) 2022 Max Kostinevich - All rights reserved.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].