laradock-multi
laradock-multi copied to clipboard
LaraDock for MSA dev env with Node.JS app
LaraDock Multi
Laradock wrapper template for running multiple related projects with different versions of PHP and Node.js such as Microservice Architecture (MSA)
Demo used
- LaraDock without rewrite original files
- Laravel with
PHP 7.4 - CoruUi as
Node.JSexample - Microservice Architecture as concept
- Docker Compose
Demo services
localhost on dev env
- default
- api.localhost
- laravel.localhost
- dashboard.localhost switched off by default
Instruction for configure step-by-step
- Integrate Demo of usage with Cloud env (
Yandex Cloudfor example as simple and useful)
Commands
cmd/bash.sh laravel- connect toLaraDock-multiservicecmd/logs.sh- waiting for all logscmd/logs.sh nginx laravel- waiting for logs of nginx andlaravelworkers or clicmd/ps.sh- shop details aboutLaraDock-multiservicescmd/rebuild.sh- remove, load updates and rebuild each oneLaraDock-multiservicescmd/rebuild.sh laravel-fpm nginxrebuild onlylaravel-fpmandnginxcmd/stop.sh- stop all servicescmd/stop.sh nginx api- stop services:nginxandapicmd/test_tor_proxy.sh- test TOR proxycmd/up.sh- start all servicescmd/up.sh nginx api- start services:nginxandapi
Setup
Install Docker-CE with Docker-compose and git
apt install docker docker-compose git
Download Laradock-Multi with laradock
git clone https://github.com/bagart/laradock-multi.git
cd laradock-multi
Autoconfigure and Auto-deploy
You cal automate Configure, Upgrade and download Laradock with command
cmd/deploy.sh
Force Upgrade Laradock Multi. It's will remove laradock path
cmd/deploy.sh upgrade
Manual Configure(upgrade) multi-env
git clone https://github.com/Laradock/laradock.git
cp ./.laradock-multi/. ./laradock/ -r
Also, you can use git submodule add https://github.com/Laradock/laradock.git
Install projects
PHP Site like Laravel
I will use dummy laravel-like php site for demo
mkdir projects/laravel
mkdir projects/laravel/public
echo '<?php phpinfo();' >> projects/laravel/public/index.php
But you can install original laravel or your exist project
composer create-project --prefer-dist laravel/laravel projects/laravel
Node.JS
I will use pretty CoreUi admin template on ReactJS
git clone https://github.com/coreui/coreui-free-react-admin-template.git projects/dashboard
cp laradock/nginx/sites/dashboard.conf.example laradock/nginx/sites/dashboard.conf
It's already added: dashboard docker in docker-compose.multi.yml.
You can copy this section for using with other node.js projects
Configure
Feel free to changing .laradock-multi options
Using
Using is similar to https://github.com/bagart/laradock_env
cmd/up.sh
Important note:
- Nginx crush in runtime after load config, if some dependency service (php-fpm, node.js) not started.
So, immediately
cmd/ps.shwill return success result and failed in next call - laravel service is empty by default
- dashboard not configured by default
HTTP Service
- dashboard take a time to building CoreUI
- dashboard:8081 direct (without
Nginx) - laravel
- api
Alternative
docker-compose override
Also you can use docker-compose.override.yml https://docs.docker.com/compose/extends/.
But it's depends on platform
cd laradock;
cp docker-compose.multi.yml docker-compose.override.yml
and remove all typical service like db or docker-in-docker
Result:
docker-compose pswill equal:docker-compose ps -f docker-compose.yml -f docker-compose.override.yml
docker-compose logswill equal:docker-compose logs -f docker-compose.yml -f docker-compose.override.yml
But docker-compose up without specs will failed
CMD from project
Open default preoject with IDE
Switch to internal bash terminal
use Laradock-multi:
cmd/up.sh
copy this dir to each new project
cp -r projects/default/cmd projects/laravel/cmd
Update
git pull
cd laradock
git pull
cd ..
add all changes
-
from:
diff .laradock-multi/docker-compose.yml.orig laradock/docker-compose.yml- to
laradock/docker-compose.multiple.ymlworkspacetoapi,laravel,defaultphp-fpmtoapi-fpm,laravel-fpm,php-fpm- each one with same name
- to
-
from:
diff .laradock-multi/env-example.orig laradock/env-example- to
laradick/.env
- to
Rebuild each Laradock-Multi service
cmd/rebuild.sh
Structure
- .laradock-multi/ - custom services path for
LaraDock- xdebug.ini - custom
xdebug.inioptions fprPHP - .env - custom php.ini options
- docker-compose.multi.yml - custom docker-compose services
- docker-compose.yml.orig - last synced original
docker-compose.yml(for diff) - env-example.orig - last synced original
.env(for diff) - node/ - new docker service template with
Node.JS - nginx/sites/ - path with custm
fcgiandproxyservices- api.conf - example with
PHP 5.6 - dashboard.conf - example with
Node.JSandCoreUi for React - laravel.conf - example Laravel on
PHP 7.4
- api.conf - example with
- xdebug.ini - custom
- cmd/ - simple command for using with autocomplete
- .jump_to_laradock.sh - cd to
LaraDockpath (for internal use) - bash.sh - connect to
LaraDock-multiservice - logs.sh -
logs -fallLaraDock-multiservice orcmd/logs.sh laravel nginxfor listed - ps.sh - show info for
LaraDock-multiservice - rebuild.sh - remove, pull and rebuild each one LaraDock-multi services or
cmd/rebuild.sh laravel nginxfor listed - stop.sh - stop
LaraDock-multiservices orcmd/stop.sh laravel nginxfor listed - up.sh - start all
LaraDock-multiservices orcmd/up.sh laravel nginxfor listed
- .jump_to_laradock.sh - cd to
- dumps/ - path for DB dumps. That will be mount inside DB-service
- laradock/ - original
laradock+laradock-multi - projects/ - custom projects
- api/ - API project with
PHP 5.6 - dashboard/ - CoreUI project with
NodeJS+React(after install) - default/ - Default localhost project for internal use or service list
- laravel/ -
Laravelproject withPHP 7.4(after install)
- api/ - API project with
- Readme.md - Readme file with instructions