Tuesday, September 6, 2022

How to Create Microservices With Laravel Octane (Swoole) Using Laravel 9 & Docker


 

Create Laravel Project

composer create-project laravel/laravel microservices-project/project-name

Install Laravel Octane

cd project-name

composer require laravel/octane

Generate laravel Key

php artisan:key generate

Clone the docker builder template

cd ..

https://github.com/panahbiru/laravel-octane-dockerfile.git

Copy the necessary files and folders from the template to Laravel Octane Project directory

cp -R laravel-octane-dockerfile/deployment project-name/deployment

cp laravel-octane-dockerfile/Dockerfile project-name/Dockerfile

cp laravel-octane-dockerfile/.dockerignore project-name/Dockerfile

Build the docker images

cd project-name/

docker build -t project-name/app-name .

wait until the building processes is finished.

Create & Run the docker container

docker run -p {portnumber}:9000 -rm project-name/app-name 

or you can run and mount the project directory to /var/www/html in the container

docker run -p {portnumber}:9000 -rm -v "$(pwd)":/var/www/html project-name/app-name


0 comments:

Post a Comment