nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.61k stars 2.36k forks source link

Allow to serve multiple applications at once #1482

Closed FazioNico closed 5 years ago

FazioNico commented 5 years ago

Expected Behavior

Not easy to work with backend + frontend together when backend is build as microservice. And if you use Angular Console you can't run more than 5 project together.

Current Behavior

At my company we currently working with backend as microservice architecture managed by Lernajs. Working fine but looking for moving to Nr to be able to have a better code sharing without npm publishing. We have multiple backend service (express) and frontend application (angular), we want to run together some of our backend service with one of our frontend application. I've try many thing to run multiples application front/backend with only once commande and the only solution have find is using concurrently to run multiple ng serve <project-name> together but when you have more than 10 project to run, it does not work anymore because it uses too much system

It will be nice to have a better solution for very large entreprise applications architecture

FrozenPandaz commented 5 years ago

Would you mind creating a repro for me to try? What is the exact error?

FazioNico commented 5 years ago

Would you mind creating a repro for me to try? What is the exact error?

@FrozenPandaz I've create a simple basic project with very simple backend and frontend here nx-issue1482 I dont have create more than 5 project but the logic is there.

It will be nice to have a dev commande to serve multiple project from ./apps folder at once.

vsavkin commented 5 years ago

@FazioNico the best option would be to define a custom target that serves a collection of microservices together. You can do it as follows in your angular.json:

{
  "projects": {
      "frontend-1": {
         "architect": {
            "serve-with-services": {
                "builder": "@nrwl/workspace:run-commands",
                "options": {
                  "commands": [
                      {
                        "command": "ng serve microservice-1"
                      },
                      {
                        "command": "ng serve microservice-2"
                      },
                      {
                        "command": "ng serve frontend1"
                      }
                  ],
                  "parallel": true
                }
             }
         }
      }
   }
}
FazioNico commented 5 years ago

@vsavkin thanks for this solution. It work find 😉

numerical25 commented 5 years ago

@vsavkin @FazioNico There is more missing to this solution. I am using angular 8 and node 12. nx is calling for there to be a root property` in the frontend-1 project. This solution could be out dated.

stefan-karlsson commented 5 years ago

@numerical25 I just tried out the proposed solution and it works fine in my Angular 8/Nest project. I just executed ng run <application-name>:serve-with-services

github-actions[bot] commented 1 year ago

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.