Search code examples
ibm-cloudangular5cloud-foundryangular2-cli

Deploying an angular 2+ app into cloud Foundry using Ng serve


I am attempting to deploy an angular app into IBM Cloud - Cloud Foundry using the CF CLI.

It always seems to fail and doing some research it requires a node script for the start command in package.json. Therefore it is failing due to me having a Ng serve command.

Any ideas about getting around this issue?


Solution

  • So after having a play I realised that the research that I have done is misleading and I have finally figured it out now. Thought that I would post my findings here to save someone else the trouble:

    • Firstly, unlike doing a ng serve locally, you will need to build the project first i.e npm run-script build. This should give you the dist directory.

    • Secondly I had a slightly invalid manifest.yml. This is a sample of the file that I have used which finally got it to work:

      ---
      applications:
      - name: <App Name>
        path: dist <- This points to the compiled code
        random-route: true
      

    Hope that this helps someone in the future.