Aug 11, 2014 Host static sites on Cloud Foundry
Introducing new staticfile-buildpack for running static sites on Cloud Foundry.
"We need a fast way to share out HTML/CSS prototypes"
$ cf push staticfile Starting app staticfile in org demo / space demo as admin... OK -----> Using root folder -----> Copying project files into public/ -----> Setting up nginx urls: staticfile.cfapps.io
We were hosting a hands-on introduction to Cloud Foundry with a client's design team. Teaching them how to use Cloud Foundry, and how to use it early and often. Production is for week 1, not for the last week of a project.
They wanted to share different branches/pull requests with internal clients/other teams. They now only need to push to their Cloud Foundry with a new app name:
touch Staticfile cf push ourproject-branchname -m 64M
dist. To target a subfolder as the root folder, add the following line to
They also wanted to be able to protect the sites with
user:password basic authentication.
Simply create a
Staticfile.auth file with each line containing
user:encryptedpassword [readme] and push again.
http://www.htaccesstools.com/htpasswd-generator/ is a good site to generate the
For example, if the username & password were both
Staticfile.auth would look like (see example app):
One line per
The solution for them was a new buildpack to make it very easy, and install it for everyone to share across the company.
$ cf buildpacks Getting buildpacks... buildpack staticfiles_buildpack java_buildpack ruby_buildpack nodejs_buildpack go_buildpack python_buildpack php_buildpack
Public Cloud Foundry?
If your Cloud Foundry, such as Pivotal Web Services does not yet support this buildpack built-in then you can specify it when you deploy/push:
cf target api.run.pivotal.io cf push myproject -m 64M -b https://github.com/cloudfoundry-community/staticfile-buildpack.git
There are some example apps with different
Read the README to learn more.