3

I'm trying to deploy angular cli project to openshift 3. It continuously failing the build with "Generic Build failure", no farther info on log. Can any one please walk me through the process if I'm wrong, and is there a way to deploy the compiled dist folder and avoid the build process or what is the best practice? Thank You in Advance. here are my scripts:

package.json

package.json

server.js

server.js

Saravana
  • 12,647
  • 2
  • 39
  • 57
Dipankar Nath
  • 31
  • 1
  • 2
  • Would you please paste build logs ? Then, someone may answer your question. – hiropon Oct 20 '17 at 04:27
  • Also, if you are building on one of the OpenShift Online Starter clusters, please note that there are [performance degradation issues reported](https://status.starter.openshift.com/) presently, so you may get varied results repeating the same builds/deployments, without an obvious error in the build log. You can also have a look on events (`oc get events`; after the build is terminated). – Jiri Fiala Oct 20 '17 at 11:14
  • there was no error log to show and no events in the console, in details tab the status says: Generic Build failure - check logs for details(Logs are not available). anyway, I moved to Heroku. things were pretty straightforward there. Thanks guys – Dipankar Nath Oct 22 '17 at 04:20
  • My experience with angular on openshift shows that these silent errors are usually due to lack of resources. Builds take a lot of resources and angular cli --prod builds are ridiculously resource hungry – Karolis Jan 12 '18 at 09:39

1 Answers1

5

The approach I use is to create a Jenkins pipeline whose build step does the following

npm install -d
npm install --save classlist.js
$(npm bin)/ng build --prod --build-optimizer
rm -rf node_modules
oc start-build angular-5-example --from-dir=. --follow

You can see that the final step is to kick off a binary build in Openshift passing the contents of the current directory (minus the node_modules which is not needed and rather large). This binary build simply copies the dist folder output of the ng build into a nginx base image plus some configuration files

FROM nginx:1.13.3-alpine
## Copy our nginx config
COPY nginx/ /etc/nginx/conf.d/
## Remove default nginx website
RUN rm -rf /usr/share/nginx/html/*
## copy over the artifacts in dist folder to default nginx public folder
COPY dist/ /usr/share/nginx/html
EXPOSE 8080

CMD ["nginx", "-g", "daemon off;"]

A fully working example application which describes how an Angular CLI generated project can be deployed to Openshift 3 can be found at

https://github.com/petenorth/angular-5-example

The application is an Angular 5 app.

Peter Fry
  • 71
  • 1
  • 5