Am trying to learn the microservice architecture by building out services using lumen and docker. I have folder structure like this
./
./base_service
./base_service/base.docker
./user_service
./user_service/user.docker
./auth_service
./auth_service/auth.docker
./gateway.docker
./vhost.conf
./docker-compose.yml
Each service directory is a lumen app This what is my docker-compose.yml file look like
version: '2'
services:
gateway:
build:
context: ./
dockerfile: web.docker
volumes:
- ./:/var/www
ports:
- "8080:80"
links:
- base_service
- auth_service
- user_service
base_service:
build:
context: ./base_service
dockerfile: base.docker
volumes:
- ./:/var/www
links:
- broker
auth_service:
build:
context: ./auth_service
dockerfile: auth.docker
volumes:
- ./:/var/www
links:
- broker
user_service:
build:
context: ./user_service
dockerfile: user.docker
volumes:
- ./:/var/www
links:
- broker
broker:
image: redis:3.0
ports:
- "63791:6379"
The gateway.docker
FROM nginx
ADD ./vhost.conf /etc/nginx/conf.d/default.conf
WORKDIR /var/www
my vhost.conf for nginx
server {
listen 80;
index index.php index.html;
root /var/www/base_service/public;
location / {
try_files $uri /index.php?$args;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass base_service:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
The docker files for the services just fetch a PHP7-fpm image
FROM php:7-fpm
RUN apt-get update && apt-get install -y libmcrypt-dev mysql-client \
&& docker-php-ext-install mcrypt pdo_mysql
WORKDIR /var/www
Running the docker-compose up -d
command and navigating to http://localhost:8080
, i get a page saying "File not found".
This my first time attempting a microservices architecture, so somewhat out of my depth with the configuration of the whole setup, any help or guidance will be greatly appreciated.