Deploying AngularJS on Scalingo

AngularJS applications can be hosted on Scalingo. It requires some specific instructions as usually the application generates static files during the deployment. And these files require a web server to be served to your clients.

Deploying an AngularJS application requires to use the Multi Buildpacks. It will be used to generate the static files using Node.js during the deployment, and run a Nginx to serve the generated files.

Create a .buildpacks file:

https://github.com/Scalingo/nodejs-buildpack
https://github.com/Scalingo/nginx-buildpack

Configure Nginx to serve the generated files by creating a nginx.conf file. The following configuration assumes that the files have been generated in the dist folder:

root /app/dist;

location / {
  try_files $uri $uri/ /index.html =404;
}

Then instruct Scalingo how to start the application with a Procfile:

web: bin/run

The bin/run script is generated during the deployment by the Nginx buildpack and starts a Nginx listening on the port defined in the PORT environment variable.


Suggest edits

Deploying AngularJS on Scalingo

©2024 Scalingo