Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to deploy angular 6 app on cloud foundry using node js buildpack?

Tags:

I want to deploy my angular 6 app on PCF as a stand alone app using nodejs buildpack. Is there a way to do that without adding the angular universal feature to it.

If it is not possible, is there a way to read PCF user provided environment variables if I deploy my app using static buildpack?

like image 778
Gururaj H Gowda Avatar asked Oct 25 '18 09:10

Gururaj H Gowda


People also ask

Where are Buildpacks stored in Cloud Foundry?

All output sent to STDOUT is relayed to the user through the Cloud Foundry Command Line Interface (cf CLI). The script is run with four arguments: The build directory for the app. The cache directory, which is a location the buildpack can use to store assets during the build process.


1 Answers

It is possible to use nginx_buildpack adding an url to nginx configuration to give access to cloudfoundry environnement variables.

Using nginx.conf in the root folder of your application :

http {
  server {
    listen {{port}};    
    root public;

    location /myenv {
        return 200 '{{ env "MYENV" }}';
    }
  }
}
events {}

Pushing the application using :

cf push <myapp> -b https://github.com/cloudfoundry/nginx-buildpack.git --no-start
cf set-env <myapp> MYENV "whatever you like"
cf start <myapp>

Then you can access from the angular application to the environment variable using /myenv

like image 144
mpromonet Avatar answered Sep 18 '22 11:09

mpromonet