Stars: 207
Forks: 83
Pull Requests: 11
Issues: 2
Watchers: 12
Last Updated: 2023-04-19 18:41:59
Pseudo-microservices project written in Laravel
License:
Languages: PHP, Shell, Dockerfile
A simple laravel pseudo-microservices demo project. This is NOT a real "microservices" setup or at least something that is production ready! It is only here to point out the separation of concerns between each service and get you started with a containerized local environment using docker with a reverse proxy on top.
This project consists of three web services user
, product
& order
and
one API gateway api-gateway
.
The webservices are containerised with Docker and are accessible within a Traefik proxy interface.
traefik
image is used for the proxy container and php:7.1-apache
is used and extended
for the web services containers & the API gateway
The api
is using the Guzzle API Client in order to maintain connection with the web services.
Lumen was preferred since it is an easy way to expose APIs.
The current Docker environment is based on Docker Toolbox. If you don't have Docker Toolbox installed, you can download it here.
docker-machine create laravel-microservices
eval $(docker-machine env laravel-microservices)
To prevent permission problems we leverage Docker-Machine-NFS to mount volumes as NFS. First, install docker-machine-nfs and then run the following command:
docker-machine-nfs laravel-microservices --nfs-config="-alldirs -maproot=0" --mount-opts="noacl,async,nolock,vers=3,udp,noatime,actimeo=1"
docker network create traefik_webgateway
# Get the ip of the VMachine
docker-machine ip laravel-microservices
# Update /etc/hosts file
192.168.99.100 lm.local user.lm.local inventory.lm.local order.lm.local api.lm.local
In order to get up and running, you need to setup each individual service.
Once you set all services, you are ready to use them.
docker-compose -f docker/docker-compose.yml up -d --build
You can access the applications from:
#user
http://user.lm.local
#inventory
http://inventory.lm.local
#order
http://order.lm.local
#api gateway
http://api.lm.local
You can access Traefik interface from:
http://lm.local:8080
docker-compose -f docker/docker-compose.yml down --volumes --remove-orphans
# DEPRECATED
docker-compose -f docker/docker-compose.yml scale ${container-name}
Removing the traefik.frontend.rule
from the Web services will make
them accessible only from the API gateway (traefik backend network)
Once you get started, you need to consider some of the following:
mysql
containers in docker/docker-compose.yml
and apply
proxy configuration in order to be able to access them.