looking for some solutions? You are welcome.

SOLVED: How to make Laravel & Lumen projects running simultaneously using docker at the same time?

Khrisna Gunanasurya:

I wonder is it possible to run both Laravel + Lumen at the same time using Docker? So I created a fresh installation of Laravel and Lumen in separate folder, so I'm going to use Lumen for the API, and I want to know if it's possible to run both of them using only 1 docker.

I already tried with changing the ports but still no luck, the Laravel running smoothly but not for the Lumen. Is there anyone else ever trying this as well?

here are the files, they are identical, but the differences are only the ports ( I don't know if what i'm doing is right or not)

docker-compose.yml

version: '2'
services:
  web:
    build:
      context: ./
      dockerfile: web.dockerfile
    volumes:
      - ./:/var/www
    ports:
      - "8080:80"
    links:
      - app

  app:
    build:
      context: ./
      dockerfile: app.dockerfile
    volumes:
      - ./:/var/www
    links:
      - database
    environment:
      - "DB_PORT=3306"
      - "DB_HOST=database"

  database:
    image: mysql:5.6
    environment:
        MYSQL_ROOT_PASSWORD: secret
        MYSQL_DATABASE: dockerApp
    ports:
        - "33061:3306"

  cache:
    image: redis:3.0
    ports: 
      - "63791:6379"

app.dockerfile

FROM php:7.1.19-fpm

RUN apt-get update && apt-get install -y libmcrypt-dev mysql-client \
    && docker-php-ext-install mcrypt pdo_mysql

WORKDIR /var/www

web.dockerfile

FROM nginx:1.10

ADD ./vhost.conf/ /etc/nginx/conf.d/default.conf

WORKDIR /var/www

vhost.conf

server {
    listen 80;
    index index.php index.html;
    root /var/www/public;

    location / {
        try_files $uri /index.php?$args;
    }

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass app:9000;
        fastcgi_index index.php;

        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }
}

docker ps

CONTAINER ID        IMAGE                           COMMAND                  CREATED             STATUS              PORTS                                      NAMES
33987802df30        test-restful-api_web            "nginx -g 'daemon of…"   34 hours ago        Up About a minute   80/tcp, 443/tcp, 0.0.0.0:32768->8001/tcp   test-restful-api_web_1
7f4b767ff2af        test-restful-api_app            "docker-php-entrypoi…"   34 hours ago        Up About a minute   9000/tcp                                   test-restful-api_app_1
be0675a6804d        redis:3.0                       "docker-entrypoint.s…"   34 hours ago        Up About a minute   6379/tcp, 0.0.0.0:63793->63792/tcp         test-restful-api_cache_1
f0b5fe2db9a4        mysql:5.6                       "docker-entrypoint.s…"   34 hours ago        Up About a minute   3306/tcp, 0.0.0.0:33063->33062/tcp         test-restful-api_database_1
bdb308c7288f        test_web                        "nginx -g 'daemon of…"   34 hours ago        Up About a minute   443/tcp, 0.0.0.0:8080->80/tcp              test_web_1
a74a1b5c2ec7        test_app                        "docker-php-entrypoi…"   34 hours ago        Up About a minute   9000/tcp                                   test_app_1
690b553eae36        mysql:5.6                       "docker-entrypoint.s…"   34 hours ago        Up About a minute   0.0.0.0:33061->3306/tcp                    test_database_1
fc47a3a84484        redis:3.0                       "docker-entrypoint.s…"   34 hours ago        Up About a minute   0.0.0.0:63791->6379/tcp                    test_cache_1

What I'm trying to achieve

I want to make something like this in the hosting test.com (the main website) and api.test.com (for restful api), but instead in my machine, I want to run it something like this (if possible) localhost:8080 (the website) localhost:8000/8001 (restful api)



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
Share:

No comments:

Recent