Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Paul_todd
Product and Topic Expert
Product and Topic Expert
Recently my colleague chris.whealy came up with an interesting problem. He had a static website that needed to be served from Cloud Foundry but he wanted a code free solution. Rather than using Node.JS and Express we felt there was probably an easier solution somewhere that could be applied to this case. From looking at the Cloud Foundry Buildpacks we found that the staticfile buildpack deploys an instance of Nginx to the server and then uploads your HTML and associated files to a folder that nginx can serve. Of course this solution is not for non static websites such as those running express which require server side code to execute to render code on the client, but for simple solution it is often overkill to do anything more than this.

 

Stark and Wayne came up with one or two good suggestions on how to use the staticfile buildpack but there was nothing around showing a very simple example.

 

To that end I decided to build one to see what it would do.

 

I created a subfolder called "src" and put my website into that along with an empty "staticfile." file. This empty file holds any configurations you might need for the buildpack or for nginx, but we do not need any.

In the root folder we create the manifest.yml file that are the deployment instructions for Cloud Foundry.



 

The manifest.yml file is also very simple:
applications:
- name: myStaticHtmlApp
instances: 1
memory: 256M
disk_quota: 256M
path: src
buildpack: https://github.com/cloudfoundry-community/staticfile-buildpack.git

 

We have a single application called myStaticHtmlApp that uses 256Mb ram and diskspace. You can probably get away with 64Mb however. The key however is the path property which defined where the source code is to upload to the nginx server. The will only upload the files in the path folder so if any temporary files are created then these should be outside the folder.

 

Login to Cloud Foundry and create a new space if you have not, making it the default space to upload app and content to. With that just do a "cf push" from the folder containing the manifest.yml file and this will create a new nginx server and deploy your source code.

 

Open your Cloud Foundry HANA Trial account and look at the default space and your app should be running there where you can open it.

 

Hopefully this has provided some insight into installing and running a codeless webserver on cloud foundry.
1 Comment