How to build and deploy Angular Universal app?

Hello :slight_smile: ,

We are using latest release of Angular Universal 9 with ivy (next-gen compatibility compiler) but we have an unexpected problem when we tried to build and deploy the app.

We launch Ivy compilation in postinstall in sync mode script in order to avoid out of memory error, but the build doesn’t works…

How to deploy our application quickly without memory error ?
We used “L” plan with 6Gb of Ram, it’s 3x more than our older PaaS system.

I provide most information about it, below :

Build Hook

yarn install
yarn run build:ssr:dev

The command build:ssr:dev launch webpack compilation :

ng run website:build:dev && ng run website:server:dev

The website will be compiled to the dist directory but this is currently not working :

Build output error log

$ ng run website:build:dev && ng run website:server:dev
        Generating ES5 bundles for differential loading...
        W: An unhandled exception occurred: Call retries were exceeded
        W: See "/tmp/ng-1pShkt/angular-errors.log" for further details.
        W: error Command failed with exit code 127.
        info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

The file /tmp/ng-1pShkt/angular-errors.log is not available, so I can’t debug log.
How to see Angular build error log ?

How to build Angular application ? (Your documentation is only for AngularJS and it’s an old version, completely differente of Angular “next gen”).

Thanks for your help :heart:

Hi Lith,

Please try adding the following to the end of your build hook to view this build error.

cat /tmp/*/angular-errors.log

Hello @jared-wright,

Thank you for your answer !
I’ve tried our solution to read error log, but the content is bit limited… :slightly_frowning_face:

[error] Error: Call retries were exceeded
            at ChildProcessWorker.initialize (/app/node_modules/jest-worker/build/workers/ChildProcessWorker.js:230:21)
            at ChildProcessWorker._onExit (/app/node_modules/jest-worker/build/workers/ChildProcessWorker.js:307:12)
            at ChildProcess.emit (events.js:310:20)
            at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)

Does it possible to have the hardware description of the Platform.sh CI ?
This error occurs with Angular sometimes because of memory limit.

Do you know if someone has already use (with success) Angular Universal on Platform.sh ?

Thanks :slight_smile:

Hi Lith,

I would check out template and example projects;

https://github.com/platformsh-templates/
https://github.com/platformsh-examples/

I would also recommend adjust your build to just perform ng run website:build:dev and start your application ng run website:server:dev using the start command. https://docs.platform.sh/languages/nodejs.html#configuration

The issue may be that you are starting your application inside the build container.

If you continue to have issues, I would recommend creating a support ticket, so we can check your project and .platform.app.yaml.

Thanks.
Platform.sh templates and examples doesn’t provide information for an Angular project for now.

Concerning the build and start part, I will try to explain how Angular Universal works, description below.

We are using Angular Universal, so we use Webpack to compile server and browser files :
I’ve separate the build in two “run”, first, we build the server files (server side) :

ng run website:server:dev

The second part build the browser files (client side) :

ng run website:build:dev

All files build with this command create a dist folder with the following tree :

/dist
    /website
       /browser   /* browser part -> client side */
           ... 
       /server     /* server part -> server side */
           main.js
           main.js.map

The server part seems to be correctly build but the browser part failed in mid-build with the error previously provided.

Then, we launch the start command with pm2 like this :

web:
  commands:
    start: "PM2_HOME=/app/run pm2 start dist/website/server/main.js"

I’ve also wrote a ticket to support in order to have some technical help with our configuration files :slight_smile:

Thanks !

Hi @Lith
I am trying to deploy an angular project too and I was wondering if you did succeed to build your angular platform.sh
If so, could you publish there the solution you have found to help beginners to find out the good way ?
Thanks in advance and best regards
Jean-François

Hi @jfvallet,

Unfortunately, Platform.sh has never found a solution to help me to deploy my Angular SSR application.
I’ve finally choose an other PaaS system, but I can’t name it here.

I’ve try during a month many solutions, support has(after two weeks) try to help me, but Platform.sh has been created initially for manage PHP applications, so this solution is clearly unadapted for Node.JS applications.

Thanks,

Hi Lith,
Sorry to read that,
Thanks a lot for your response
Bests regards