2

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.

MrFoh
  • 145
  • 2
  • 2
  • 10
  • I don't know any docker, but I had a 'file not found' issue recently with nginx and php-fpm. Issue was a misconfiguration with the `SCRIPT_FILENAME` when I started chrooting my php-fpm workers. Have you set the `chroot` setting? – Daniel Oct 30 '16 at 20:14

1 Answers1

2

I had the similar problem as I tried to imitate the things stated : here. Finally, I figured out that the problem was I had to put all those files in the PROJECT ROOT (and not create a project inside it!). After making these changes, I was able to work on my project flawlessly. Hope this helps you too.