Giter Site home page Giter Site logo

staticfile-buildpack's Introduction

Cloud Foundry Staticfile Buildpack

CF Slack Join us on Slack

A Cloud Foundry buildpack for static content such as websites (HTML/JS/CSS).

Buildpack User Documentation

Official buildpack documentation can be found at staticfile buildpack docs.

Building the Buildpack

To build this buildpack, run the following commands from the buildpack's directory:

  1. Source the .envrc file in the buildpack directory.

    source .envrc

    To simplify the process in the future, install direnv which will automatically source .envrc when you change directories.

  2. Install buildpack-packager

    go install github.com/cloudfoundry/libbuildpack/packager/buildpack-packager
  3. Build the buildpack

    buildpack-packager build [ --cached=(true|false) ]
  4. Use in Cloud Foundry

    Upload the buildpack to your Cloud Foundry and optionally specify it by name

    cf create-buildpack [BUILDPACK_NAME] [BUILDPACK_ZIP_FILE_PATH] 1
    cf push my_app [-b BUILDPACK_NAME]

Testing

To test this buildpack, run the following commands from the buildpack's directory:

  1. Source the .envrc file in the buildpack directory.

    source .envrc

    To simplify the process in the future, install direnv which will automatically source .envrc when you change directories.

  2. Run unit tests

    ./scripts/unit.sh
  3. Run integration tests

    Buildpacks use the Cutlass framework for running integration tests against Cloud Foundry. Before running the integration tests, you need to login to your Cloud Foundry using the cf cli:

    cf login -a https://api.your-cf.com -u [email protected] -p pa55woRD

    Note that your user requires permissions to run cf create-buildpack and cf update-buildpack. To run the integration tests, run the following command from the buildpack's directory:

    ./scripts/integration.sh

More information can be found on here.

Contributing

Find our guidelines here.

Help and Support

Join the #buildpacks channel in our Slack community if you need any further assistance.

Reporting Issues

Open a GitHub issue on this project here.

Active Development

The project backlog is on Pivotal Tracker.

Acknowledgements

This buildpack is based heavily upon Jordon Bedwell's Heroku buildpack and the modifications by David Laing for Cloud Foundry nginx-buildpack (deprecated). It has been tuned for usability (configurable with Staticfile) and to be included as a default buildpack (detects Staticfile rather than the presence of an index.html). Thanks for the buildpack Jordon! If you require additional custom NGINX configuration, use the new nginx-buildpack.

staticfile-buildpack's People

Contributors

ameyer-pivotal avatar arjun024 avatar arthfl avatar astrieanna avatar brayanhenao avatar cf-buildpacks-eng avatar crawsible avatar dannyzen avatar davidjahn avatar dependabot[bot] avatar dgodd avatar drnic avatar dwillist avatar flavorjones avatar foresteckhardt avatar geramirez avatar jfeeny avatar jtarchie avatar jvshahid avatar kardolus avatar mhoran avatar mrdavidlaing avatar rochesterinnyc avatar rogeruiz avatar ryanmoran avatar sesmith177 avatar simonjohansson avatar styeung avatar thitch97 avatar tisvictress avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

staticfile-buildpack's Issues

v1.7.4 of nginx fails to run

Using cf-ssh.yml to login:

vcap@1802270ajg4:~$ sh boot.sh 
/home/vcap/app/nginx/sbin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory

Consider responding with a "Vary: accept-encoding" header

This is a feature request.

There was a recent blog post about the Vary response header:

https://www.fastly.com/blog/best-practices-for-using-the-vary-header

which indicates that caching may not work as expected unless it's set to allow the cache to key on accept-encoding values. I'll let the article provide the value proposition.

We could respond with this header by setting "gzip_vary on" in the default nginx.conf file.

There are reports (generally a few years old) that this header can trigger bugs in msie6 and earlier, but I've been unable to find recent reports of this. It's the only reason I can think of to reject this feature request.

I'd love to hear people's thoughts.

Include ngx_pagespeed

What version of Cloud Foundry are you using?
220

What version of the buildpack you are using?
1.3.9

If you were attempting to accomplish a task, what was it you were attempting to do?
Enable pagespeed via custom nginx.conf

What did you expect to happen?
The pagespeed module to start processing requests

What was the actual behavior?
ngx_pagespeed is not included in the nginx package, so nginx fails because of unknown configuration directive.

We briefly discussed the purpose of pagespeed over https://cloudfoundry.slack.com/archives/buildpacks/p1468242176000666 and decided to file a ticket.

Fail to clone git repository error

I am just following the sample code: cf push my-site -m 64M -b https://github.com/cloudfoundry/staticfile-buildpack.git, however, I got fail to clone git repository error, any idea here? May thanks!


2016-01-11T03:02:49.000+00:00 [API] OUT Created app with guid 596ac6fa-1a5d-4116-859c-1f8f3fba72d1
2016-01-11T03:02:54.000+00:00 [API] OUT Updated app with guid 596ac6fa-1a5d-4116-859c-1f8f3fba72d1 ({"route"=>"1809d969-750e-4d1e-a4d0-62315d3c1255"})
2016-01-11T03:03:06.000+00:00 [API] OUT Updated app with guid 596ac6fa-1a5d-4116-859c-1f8f3fba72d1 ({"state"=>"STARTED"})
2016-01-11T03:03:06.000+00:00 [STG] OUT Creating container
2016-01-11T03:03:15.000+00:00 [STG] OUT Successfully created container
2016-01-11T03:03:15.000+00:00 [STG] OUT Downloading app package...
2016-01-11T03:03:15.000+00:00 [STG] OUT Downloaded app package (5M)
2016-01-11T03:03:15.000+00:00 [STG] OUT Downloading buildpacks (https://github.com/cloudfoundry/staticfile-buildpack.git)...
2016-01-11T03:03:16.000+00:00 [STG] OUT Downloaded buildpacks
2016-01-11T03:03:16.000+00:00 [STG] OUT Staging...
2016-01-11T03:03:16.000+00:00 [STG] ERR Failed to clone git repository at https://github.com/cloudfoundry/staticfile-buildpack.git
2016-01-11T03:03:16.000+00:00 [STG] OUT Exit status 1
2016-01-11T03:03:16.000+00:00 [STG] ERR Staging failed: Exited with status 1
2016-01-11T03:03:16.000+00:00 [API] ERR Failed to stage application: staging failed


Add LUA to the buildpack

Feature request:

I have been working with the staticfile-buildpack for a while and I have a question/feature request. I am trying to do URL rewrites, to make sure my urls are always lowercase. I came across this tutorial to do it with Perl/LUA. As LUA is faster the latter is preferred.

Can this be added to the buildpack? (Or, in the case that's not going to happen, give thoughts on how to do this with an other buildpack)

Allow specification of alternate nginx builds

In some cases, it's useful to be able to use a non-standard version of nginx--for example, to use a non-core module or fork with extra functionality. I ran into this recently on a project where I wanted to use some functions from the set_misc module.

I wound up rebuilding nginx with the extensions I wanted and adding a check to compile to look for an nginx.tgz file in the app directory, and use that file instead of downloading if it exists--see jmcarp@e1a77e1. But maybe there's a more elegant way to handle this. I'd be happy to write up a patch if folks are interested in exposing this kind of option.

Mail module missing

I am using latest code. I was trying to use mail proxy in nginx but I am getting error pushing the app. Mail directives is missing. Let me know how to fix this.

Dotfiles are not moved/copied into public/

As part of the compile, files in $root_dir are moved into public/.

There are a few issues:

  1. |mv| doesn't include dotfiles/dot-directories, so we end up with some files present in public/ and some left behind. I believe we should move/copy all files, since (a) that seems more predictable, and (b) people can already exclude files using their manifest (and in fact the default ignore-files excludes dotfiles anyway).
  2. The message says "Copying", but we use |mv|. We should change one or the other.

Buildpack compilation step failed

cf push [APP-NAME] -m 64M -b https://github.com/cloudfoundry/staticfile-buildpack.git

2015-06-24T17:13:09.79-0500 [API/0] OUT Created app with guid f6190014-5afd-49df-bcbf-6c1bbd5359c5
2015-06-24T17:13:22.24-0500 [API/0] OUT Updated app with guid f6190014-5afd-49df-bcbf-6c1bbd5359c5 ({"route"=>"b2c7e243-7ee8-4f41-9cec-640d2105a59a"})
2015-06-24T17:14:17.11-0500 [DEA/41] OUT Got staging request for app with id f6190014-5afd-49df-bcbf-6c1bbd5359c5
2015-06-24T17:14:22.97-0500 [API/1] OUT Updated app with guid f6190014-5afd-49df-bcbf-6c1bbd5359c5 ({"state"=>"STARTED"})
2015-06-24T17:14:23.09-0500 [STG/41] OUT -----> Downloaded app package (2.8M)
2015-06-24T17:14:23.24-0500 [STG/0] ERR Cloning into '/tmp/buildpacks/staticfile-buildpack'...
2015-06-24T17:14:23.85-0500 [STG/0] OUT Submodule 'compile-extensions' (https://github.com/cloudfoundry-incubator/compile-extensions.git) registered for path 'compile-extensions'
2015-06-24T17:14:23.90-0500 [STG/0] ERR Cloning into 'compile-extensions'...
2015-06-24T17:14:24.54-0500 [STG/0] OUT Submodule path 'compile-extensions': checked out '1f260464c156bddfb654adb14298344797d030a1'
2015-06-24T17:14:24.62-0500 [STG/0] ERR It looks like you're deploying on a stack that's not supported by this buildpack.
2015-06-24T17:14:24.62-0500 [STG/0] ERR That could be because you're using a recent buildpack release on a deprecated stack.
2015-06-24T17:14:24.62-0500 [STG/0] ERR If you're using the buildpack installed by your CF admin, please let your admin know you saw this error message.
2015-06-24T17:14:24.62-0500 [STG/0] ERR If you at one point specified a buildpack that's at git URL, please make sure you're pointed at a version that supports this stack.
2015-06-24T17:14:24.63-0500 [STG/0] OUT Staging failed: Buildpack compilation step failed
2015-06-24T17:14:24.94-0500 [API/1] ERR encountered error: App staging failed in the buildpack compile phase

RFC: Ability to include an nginx config

The current functionality of the staticfile-buildpack is to overwrite the provided nginx.conf if a user-provided one exists. The Buildpacks team is curious if users are interested in the ability to add a non-destructive nginx-additions.conf config file, which, if provided, would exist additively on top of the current config.

If you find this idea compelling, please comment on the issue as we'd like to talk to you a bit more about the expected functionality.

Thanks for your time

Compile the authentication module with nginx to enable basic auth against LDAP/AD

We would like to add authentication modules to nginx. (ldap-auth) (i.e. https://github.com/nginxinc/nginx-ldap-auth or https://github.com/kvspb/nginx-auth-ldap)

We have a growing need to force authentication for static sites, and in apache I would use user-binded auth (we do not want to provide a system ID to bind because that introduces sensitive credentials to source), looks like nginx needs custom modules for that.

The use case is that inside our large corporate environment all sites must require authentication. We are not so concerned with authorization, though that would be a nice perk. We just need to ensure that whoever is trying to access the site is a valid employee with active credentials, and not one of the many vendors and visitors with access to a LAN port.

I threw this out to the buildpack community on Slack who suggested I log this enhancement request. Please let me know if details below are not sufficient.
https://cloudfoundry.slack.com/archives/buildpacks/p1461159231000083

What version of Cloud Foundry are you using?

What version of the buildpack you are using?
1.3.6

If you were attempting to accomplish a task, what was it you were attempting to do?
Enable basic auth to bind against LDAP with user provided credentials.

What did you expect to happen?

  1. Able to configure LDAP endpoint, uid, and LDAP tree needed to bind as user and validate password.
  2. User attempts to view site using static build pack
  3. User is prompted for enterprise ID and password
  4. User credentials are used in attempt to bind to LDAP/AD server
  5. Only if bind is successful can user view site.

What was the actual behavior?
Not available.

Please confirm where necessary:

  • I have included a log output
  • My log includes an error message
  • I have included steps for reproduction

N/A - new feature request, not a bug.

how to force https

I noticed that all my apps using this buildpack default to http. I saw in the nginx.conf that there's a way to force https using an ENV variable called FORCE_HTTPS. I set that variable in my manifest file using

env:
  FORCE_HTTPS: true

but the apps still default to http. Am I doing something wrong? Can you please document this feature?

ERR Cloning into '/tmp/buildpacks/staticfile-buildpack'... && ERR Cloning into 'compile-extensions'...

I start my applications as follow:

$ cf push recorditblog -m 128M -p public -b https://github.com/cloudfoundry/staticfile-buildpack.git
Updating app recorditblog in org Recorditblog / space production as [email protected]...
OK

Uploading recorditblog...
Uploading app files from: public
Uploading 2.8M, 549 files
Done uploading
OK

Stopping app recorditblog in org Recorditblog / space production as [email protected]...
OK

Starting app recorditblog in org Recorditblog / space production as [email protected]...
-----> Downloaded app package (2.5M)
-----> Downloaded app buildpack cache (4.0K)
Cloning into '/tmp/buildpacks/staticfile-buildpack'...
Submodule 'compile-extensions' (https://github.com/cloudfoundry-incubator/compile-extensions.git) registered for path 'compile-extensions'
Cloning into 'compile-extensions'...
Submodule path 'compile-extensions': checked out 'ce9345a9a6e7b00266194cadd18dbef37e791a7b'
-------> Buildpack version 1.2.1
-----> Using root folder
-----> Copying project files into public/
-----> Setting up nginx
-----> Uploading droplet (6.5M)

1 of 1 instances running

App started

OK

App recorditblog was started using this command sh boot.sh

Showing health and status for app recorditblog in org Recorditblog / space production as [email protected]...
OK

requested state: started
instances: 1/1
usage: 128M x 1 instances
urls: recorditblog.cfapps.io, www.recorditblog.com
last uploaded: Fri Sep 4 09:43:06 UTC 2015
stack: cflinuxfs2

 state     since                    cpu    memory          disk          details   

#0 running 2015-09-04 11:43:25 AM 0.0% 22.2M of 128M 60.9M of 1G

Everything looks fine, but then I can't access my website.

So I took a look at the logs:

2015-09-04T11:43:13.93+0200 [DEA/15] OUT Got staging request for app with id c0499ddb-6459-42ba-8984-b04bf6f812a3
2015-09-04T11:43:15.33+0200 [API/5] OUT Updated app with guid c0499ddb-6459-42ba-8984-b04bf6f812a3 ({"state"=>"STARTED"})
2015-09-04T11:43:15.62+0200 [STG/15] OUT -----> Downloaded app package (2.5M)
2015-09-04T11:43:15.68+0200 [STG/15] OUT -----> Downloaded app buildpack cache (4.0K)
2015-09-04T11:43:15.86+0200 [STG/0] ERR Cloning into '/tmp/buildpacks/staticfile-buildpack'...
2015-09-04T11:43:16.21+0200 [STG/0] OUT Submodule 'compile-extensions' (https://github.com/cloudfoundry-incubator/compile-extensions.git) registered for path 'compile-extensions'
2015-09-04T11:43:16.23+0200 [STG/0] ERR Cloning into 'compile-extensions'...
2015-09-04T11:43:16.57+0200 [STG/0] OUT Submodule path 'compile-extensions': checked out 'ce9345a9a6e7b00266194cadd18dbef37e791a7b'
2015-09-04T11:43:16.62+0200 [STG/0] OUT -------> Buildpack version 1.2.1
2015-09-04T11:43:16.79+0200 [STG/0] OUT -----> Using root folder
2015-09-04T11:43:16.79+0200 [STG/0] OUT -----> Copying project files into public/
2015-09-04T11:43:17.02+0200 [STG/0] OUT -----> Setting up nginx
2015-09-04T11:43:18.69+0200 [STG/15] OUT -----> Uploading droplet (6.5M)
2015-09-04T11:43:23.21+0200 [DEA/15] OUT Starting app instance (index 0) with guid c0499ddb-6459-42ba-8984-b04bf6f812a3
2015-09-04T11:43:25.12+0200 [App/0] OUT ==> /home/vcap/app/nginx/logs/access.log <==
2015-09-04T11:43:25.12+0200 [App/0] OUT ==> /home/vcap/app/nginx/logs/error.log <==

Any idea ?

Default configuration outputs redundant access logs (mostly duplicate of RTR logs)

By default, the static buildpack configure nginx to produce access logs on ephemeral FS, and then streams them to stdout

2016-03-14T14:53:36.32+0100 [RTR/0]      OUT test-status.mysite.org - [14/03/2016:13:53:36 +0000] "GET /hello.txt HTTP/1.1" 200 0 6 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:44.0) Gecko/20100101 Firefox/44.0" 192.168.26.30:51519 x_forwarded_for:"10.[...]" x_forwarded_proto:"http" vcap_request_id:cb89cf0e-2adc-4e14-5c7c-06c824d683c6 response_time:0.002860578 app_id:f55fd562-a491-45f1-ac3e-38aa7f73952a
2016-03-14T14:53:37.06+0100 [APP/0]      OUT ==> /home/vcap/app/nginx/logs/access.log <==
2016-03-14T14:53:37.06+0100 [APP/0]      OUT 10.[...] - - - [14/Mar/2016:13:53:36 +0000] "GET /hello.txt HTTP/1.1" 200 6

The information is roughly the same as what provided by default by the gorouter, with mostly format change, with the polluting trace from the cat command listing the ephemeral FS log path.

It does not seem a very useful default to have, as this mostly appear as duplicated logs, and would slightly impact performance without real benefits by default.

More over, it might be worth checking that the default log is indeed rotated and does not end up filling up the ephemeral FS max quota until the garden FS limit is reached and the app will be crashed by garden.

https://www.nginx.com/resources/wiki/start/topics/examples/logrotation/

Suggesting to turn off the nginx access log file by default.

precise support available

Hi, I was trying this out on HDP 1.1, and seems like my docker images are precise. Is there any reason we wouldn't want to add precise to the Vagrantfile to get some precise vendor images?

access_log syslog:server=xxx in nginx.conf not working

I'm forwarding Nginx access log to Logentries. I added this line to nginx.config and push to Bluemix but doesn't work. Here is the line:

"access_log syslog:server=xxx,logentries.com:xxxx cloudfoundry;"

Is this supported? It works on my local machine, Macbook and Ubuntu.

Support for cflinuxfs2.

On a fresh CF 205 installation,

$ mkdir /tmp/kehe && cf /tmp/kehe
$ touch Staticfile
$ cf push my-site -m 64M -b https://github.com/cloudfoundry-community/staticfile-buildpack.git -s cflinuxfs2

When cf logs my-site in another terminal I see

2015-03-26T15:59:42.68+0100 [App/0]      ERR /home/vcap/app/nginx/sbin/nginx: error while loading shared libraries: libssl.so.0.9.8: cannot open shared object file: No such file or directory
2015-03-26T15:59:42.71+0100 [DEA/1]      ERR Instance (index 0) failed to start accepting connections

Using the normal lucid64 stack works like a charm.

More info about cflinuxfs2, https://groups.google.com/a/cloudfoundry.org/forum/#!topic/vcap-dev/gU7rpD8MSC

Http/2 support

Is there any way to use http/2 with this, since nginx support it ?

Thanks !

Read logs from nginx

Hi,

I have just deployed an static application, but I think that exist some kind of problem and I would like to read the logs from the nginx to understand the source of the problem?

Paths:

/home/vcap/app/nginx/logs/access.log
/home/vcap/app/nginx/logs/error.log 

Shell output:

cf logs  StaticWebsiteHelloWorld --recent
Connected, dumping recent logs for app StaticWebsiteHelloWorld in org DevBox / s
pace dev as admin...

2015-08-04T11:44:04.21+0200 [API/0]      OUT Created app with guid f8735892-991d-4b3f-ac71-20fa22887252
2015-08-04T11:44:07.55+0200 [API/0]      OUT Updated app with guid f8735892-991d-4b3f-ac71-20fa22887252 ({"route"=>"96995468-8b8a-4319-944e-961d82138226"})
2015-08-04T11:44:11.43+0200 [DEA/0]      OUT Got staging request for app with id
 f8735892-991d-4b3f-ac71-20fa22887252
2015-08-04T11:44:12.35+0200 [API/0]      OUT Updated app with guid f8735892-991d-4b3f-ac71-20fa22887252 ({"state"=>"STARTED"})
2015-08-04T11:44:12.40+0200 [STG/0]      OUT -----> Downloaded app package (4.0K)
2015-08-04T11:44:12.47+0200 [STG/0]      ERR     Cloning into '/tmp/buildpacks/staticfile-buildpack'...
2015-08-04T11:44:13.78+0200 [STG/0]      OUT     Submodule 'compile-extensions'
(https://github.com/cloudfoundry-incubator/compile-extensions.git) registered for path 'compile-extensions'
2015-08-04T11:44:13.80+0200 [STG/0]      ERR Cloning into 'compile-extensions'...
2015-08-04T11:44:15.10+0200 [STG/0]      OUT Submodule path 'compile-extensions': checked out 'ce9345a9a6e7b00266194cadd18dbef37e791a7b'
2015-08-04T11:44:15.14+0200 [STG/0]      OUT -------> Buildpack version 1.2.1
2015-08-04T11:44:17.07+0200 [STG/0]      ERR grep: Staticfile: No such file or directory
2015-08-04T11:44:17.07+0200 [STG/0]      OUT -----> Using root folder
2015-08-04T11:44:17.07+0200 [STG/0]      OUT -----> Copying project files into public/
2015-08-04T11:44:17.11+0200 [STG/0]      OUT -----> Setting up nginx
2015-08-04T11:44:17.17+0200 [STG/0]      ERR grep: Staticfile: No such file or directory
2015-08-04T11:44:17.75+0200 [STG/0]      OUT -----> Uploading droplet (2.5M)
2015-08-04T11:44:20.15+0200 [DEA/0]      OUT Starting app instance (index 0) with guid f8735892-991d-4b3f-ac71-20fa22887252
2015-08-04T11:44:21.19+0200 [App/0]      OUT     ==> /home/vcap/app/nginx/logs/access.log <==
2015-08-04T11:44:21.19+0200 [App/0]      OUT ==> /home/vcap/app/nginx/logs/error.log <==

Many thanks in advance.

Juan Antonio

add caching to nginx.conf

I think caching might greatly improve the performance of the apps served by this buildpack. My suggestion would be to add something like

location ~* \.(jpe?g|png|gif|ico|svg|css|js|eot|ttf|woff|woff2)$ {
  expires 1M;
}

to the nginx.conf file. It sure isn't the most sophisticated configuration for caching but it's pretty generic.

Avoid use of ephemeral FS for nginx error logs: nginx can output logs to sdterr

Currently nginx error logs are written to ephemeral FS and then streamed using the cat command.

Also, it might be worth checking that the error log is indeed rotated and does not end up filling up the ephemeral FS max quota until the garden FS limit is reached and the app will be crashed by garden.

It seems nginx supports outputing them directly to stderr instead of going to ephemeral FS, see http://nginx.org/en/docs/ngx_core_module.html#error_log which would make this more optimal and safe.

The first parameter defines a file that will store the log. The special value stderr selects the standard error file.

how can I add a text/cache-manifest mime type

I'd like to add a mime type to serve a text/cache-manifest manifest file from my app.

I'm trying to create a html5 offline app. I could use the php buildpack to accomplish this, but it seems like overkill given this app has no local NETWORK resources in the manifest.

If you would accept this in mime.types globally I'll do a pull request ASAP.

If a public folder exists in the app, the build fails.

2015-03-30T13:43:22.91+0200 [STG/7]      OUT -----> Downloaded app package (2.0M)
2015-03-30T13:43:23.66+0200 [STG/0]      ERR Cloning into '/tmp/buildpacks/staticfile-buildpack'...
2015-03-30T13:43:25.89+0200 [STG/0]      ERR grep: Staticfile: No such file or directory
2015-03-30T13:43:25.89+0200 [STG/0]      OUT -----> Using root folder
2015-03-30T13:43:25.89+0200 [STG/0]      OUT -----> Copying project files into public/
2015-03-30T13:43:26.03+0200 [STG/0]      ERR mv: cannot move `/tmp/cache/public' to `./public': Directory not empty
2015-03-30T13:43:26.04+0200 [STG/0]      OUT Staging failed: Buildpack compilation step failed
2015-03-30T13:43:26.21+0200 [API/1]      ERR Encountered error: App staging failed in the buildpack compile phase
2015-03-30T13:49:

Which is a real bummer since all our apps have a public folder. -.-
Issue might be caused by 7958492

No buildpack version is given in output

While uploading a static site:

○ → cf push [redacted] -m 64M
[redacted]
OK

Creating route [redacted].cfapps.io...
OK

Binding [redacted].cfapps.io to war-download...
OK

Uploading war-download...
Uploading app files from: /Users/pivotal/workspace/[redacted]
Uploading 32.7M, 2 files
Done uploading
OK

[redacted]
-----> Downloaded app package (33M)
-----> Using root folder
-----> Copying project files into public/
-----> Setting up nginx

-----> Uploading droplet (68M)

1 of 1 instances running

App started


OK

App war-download was started using this command `sh boot.sh`

[redacted]
OK

requested state: started
instances: 1/1
usage: 64M x 1 instances
urls: [redacted].cfapps.io
last uploaded: Wed Jun 24 17:45:20 UTC 2015
stack: cflinuxfs2

     state     since                    cpu    memory         disk          details
#0   running   2015-06-24 01:45:45 PM   0.0%   22.8M of 64M   70.8M of 1G

Other buildpacks advertise their version during staging.

directory listing without trailing slash redirects to incorrect location

When Staticfile has directory: visible enabled, if you visit a directory without a trailing slash the app tries to redirect to the URL with the trailing slash. With CloudFoundry, it appends the port of the app on to the URL.

Steps to recreate:

mkdir fancy_dir/
touch bert.txt
echo 'directory: visible' > Staticfile
cf push my-app -b https://github.com/cloudfoundry-incubator/staticfile-buildpack
open http://my-app.cf-apps.io/fancy_dir

Noticed that the directory does not properly redirect.

Allowed directives on custom nginx.conf

ERR 2015/10/11 12:51:50 [emerg] 29#0: "server" directive is not allowed here in /home/vcap/app/nginx/conf/nginx.conf:4

ERR 2015/10/11 12:48:50 [emerg] 29#0: "upstream" directive is not allowed here in /home/vcap/app/nginx/conf/nginx.conf:3

Can you please give examples of allowed directives in a custom nginx.conf?

Specifying "root:" in a Staticfile with Windows line endings results in error

STR:

  1. Create a Staticfile containing two lines like so:
root: foo

...that has Windows line endings.
2) Create an empty directory named "foo" in the same location
3) cf push my-site -m 64M -b https://github.com/cloudfoundry-community/staticfile-buildpack.git

Expected:
Works the same as if the Staticfile has unix line endings.

Actual:
2015-03-17T23:48:50+0000 staging: mv: cannot stat `src\r/*': No such file or directory

This is because of:
https://github.com/cloudfoundry-incubator/staticfile-buildpack/blob/master/bin/compile#L28
root_dir=$(grep root: Staticfile | sed -e 's/^root: *//')

It catches trailing whitespace (in this case the carriage return).

manifest.yml is moved to public/

My app uses stackato.yml, which isn't included in my push.
However manifest.yml is then generated from it, which ends up being placed in public/, unless I set a custom root in Staticfile.

I'm presuming this isn't intentional?

spurious error messages when pushing a project without a Staticfile

What version of Cloud Foundry are you using?

latest

What version of the buildpack you are using?

v1.3.6

If you were attempting to accomplish a task, what was it you were attempting to do?

Pushing a static site using -b staticfile_buildpack when the directory doesn't contains a Staticfile file

What did you expect to happen?

I expected to see no errors

What was the actual behavior?

Following output contains error messages from failed grep commands:

Downloading staticfile_buildpack...
Downloaded staticfile_buildpack
Creating container
Successfully created container
Downloading app package...
Downloaded app package (63.9K)
Staging...
-------> Buildpack version 1.3.6
Downloaded [file:///tmp/buildpacks/a0196007b227496ea71bcdcdd0e4f798/dependencies/https___pivotal-buildpacks.s3.amazonaws.com_concourse-binaries_nginx_nginx-1.9.14-linux-x64.tgz]
grep: Staticfile: No such file or directory
-----> Using root folder
-----> Copying project files into public/
-----> Setting up nginx
grep: Staticfile: No such file or directory
grep: Staticfile: No such file or directory
Exit status 0
Staging complete
Uploading droplet, build artifacts cache...
Uploading build artifacts cache...
Uploading droplet...
Uploaded build artifacts cache (108B)
Uploaded droplet (2.5M)
Uploading complete

1 of 1 instances running

Please confirm where necessary:

  • I have included a log output
  • My log includes an error message
  • I have included steps for reproduction

how to use this buildpack in eclipse

I have read how to install this buildpack in cloud. but I have the other question, hope somebody can answer it.

I write AngularJS code using Webstorm IDE. I just want to push this AngularJs Web Application in cloud foundry. The following steps should be done.

  1. install staticfile buildpack firstly in cloud.
  2. push AngularJS application to clound.

Is that right??

My Question.
How can I use Eclipse or Webstorm to deploy Angular JS using staticfile buildpack.

can someone give some example?

Thanks a lot

LH

deployment failure to lucid64

Hi, I'm trying to deploy a static site using this buildpack to IBM Bluemix and I receive the following error:

ERR Cloning into '/tmp/buildpacks/staticfile-buildpack'...
OUT Submodule 'compile-extensions' (https://github.com/cloudfoundry-incubator/compile-extensions.git) registered for path 'compile-extensions'
ERR Cloning into 'compile-extensions'...
OUT Submodule path 'compile-extensions': checked out 'ce9345a9a6e7b00266194cadd18dbef37e791a7b'
ERR It looks like you're deploying on a stack (currently set to *lucid64*) that's not supported by this buildpack.
ERR That could be because you're using a recent buildpack release on a deprecated stack.

Seems like compile-extensions doesn't support lucid64 (if I'm reading the logs correctly) but the CHANGELOG here seems to indicate it should still be supported. Possibly staticfile should indicate that due to the dependency on complie-extensions lucid64 is not support?

Any ideas on how I could still use staticfile with Bluemix (a matter of getting compile-extensions to support lucid64?).

Feature request: HSTS support

In #37 there was a discussion of how to best implement HTTP Strict Transport Security.

I agree with that conversation that the best place to store this configuration is the Staticfile.

One caveat is that I wouldn't want this activated in any environments where HTTPS wasn't enabled, since any users that hit the site while it's deployed that way would be blocked from hitting the HTTP site for a long time.

Therefore it probably makes the most sense to require the FORCE_HTTPS environment variable to be set as well before this would take any effect. (Maybe that should be moved to the Staticfile as well?)

build commands

A question just came up of "how would I host a Jekyll site on Cloud Foundry?", and it's not obvious about the best way to have Cloud Foundry build a static site (for Jekyll, Hugo, etc.), as opposed to simply hosting the precompiled files. What's the best way to do this?

Enabling `FORCE_HTTPS` in Bluemix + CloudFlare (Flexible) triggers infinite redirect loop

Originally reported as #55 (comment)

What version of Cloud Foundry are you using?

IBM Bluemix. cf version 6.21.0+dff2cf8-2016-07-27

What version of the buildpack you are using?

-------> Buildpack version 1.3.6
Downloaded [file:///var/vcap/data/dea_next/admin_buildpacks/d7214a80-2e86-49ea-987d-c06f376ff950_de3bedc191535d4743e0b391458736b183f9209b/dependencies/https___pivotal-buildpacks.s3.amazonaws.com_concourse-binaries_nginx_nginx-1.9.14-linux-x64.tgz]

If you were attempting to accomplish a task, what was it you were attempting to do?

Redirect http -> https

What did you expect to happen?

  1. For HTTP connection (only!), redirect to HTTPS. By the way, Bluemix always connects to app as HTTP
  2. For HTTPS, stay that way. By the way, CloudFlare SSL can be configured to be Flexible, Full, Full (Strict), see https://support.cloudflare.com/hc/en-us/articles/200170516-How-do-I-add-SSL-to-my-site-
  3. If I comment the FORCE_HTTPS in manifest, it will no longer provide https redirection.

What was the actual behavior?

  1. Even if I comment FORCE_HTTPS: true in manifest, or I set FORCE_HTTPS: false, the https redirection is still being done.
  2. Server always issues a redirect, even if browser accesses via https.

Server:

App/0162.158.162.29, 108.168.250.152 - - - [11/Aug/2016:03:31:49 +0000] "GET / HTTP/1.1" 301 1782016-08-11T10:31:49.741+0700
RTR/1eragano.com - [11/08/2016:03:31:49.735 +0000] "GET / HTTP/1.1" 301 0 178 "-" "curl/7.49.1" 108.168.250.152:19570 x_forwarded_for:"162.158.162.29" x_forwarded_proto:"http" vcap_request_id:6fe316d2-1b63-4f98-67c5-b76c1bef074a response_time:0.004735874 app_id:3eb4af31-6082-42db-b363-d9709803d8bc x_global_transaction_id:"3058027583"

Client:

$ curl  -v https://www.eragano.com/
* timeout on name lookup is not supported
*   Trying 104.28.12.205...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* Connected to www.eragano.com (104.28.12.205) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
*   CAfile: C:\Users\ceefour\.lein\bin\curl-ca-bundle.crt
  CApath: none
* TLSv1.2 (OUT), TLS header, Certificate Status (22):
} [5 bytes data]
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
} [512 bytes data]
* TLSv1.2 (IN), TLS handshake, Server hello (2):
{ [102 bytes data]
* TLSv1.2 (IN), TLS handshake, Certificate (11):
{ [3424 bytes data]
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
{ [149 bytes data]
* TLSv1.2 (IN), TLS handshake, Server finished (14):
{ [4 bytes data]
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
} [70 bytes data]
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
} [1 bytes data]
* TLSv1.2 (OUT), TLS handshake, Finished (20):
} [16 bytes data]
* TLSv1.2 (IN), TLS change cipher, Client hello (1):
{ [1 bytes data]
* TLSv1.2 (IN), TLS handshake, Finished (20):
{ [16 bytes data]
* SSL connection using TLSv1.2 / ECDHE-ECDSA-AES128-GCM-SHA256
* ALPN, server accepted to use h2
* Server certificate:
*  subject: OU=Domain Control Validated; OU=PositiveSSL Multi-Domain; CN=sni76253.cloudflaressl.com
*  start date: Aug  9 00:00:00 2016 GMT
*  expire date: Feb 12 23:59:59 2017 GMT
*  subjectAltName: host "www.eragano.com" matched cert's "*.eragano.com"
*  issuer: C=GB; ST=Greater Manchester; L=Salford; O=COMODO CA Limited; CN=COMODO ECC Domain Validation Secure Server CA 2
*  SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* TCP_NODELAY set
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
} [5 bytes data]
* Using Stream ID: 1 (easy handle 0x68ce90)
} [5 bytes data]
> GET / HTTP/1.1
> Host: www.eragano.com
> User-Agent: curl/7.49.1
> Accept: */*
>
{ [5 bytes data]
* Connection state changed (MAX_CONCURRENT_STREAMS updated)!
} [5 bytes data]
* HTTP 1.0, assume close after body
< HTTP/2 301
< date: Thu, 11 Aug 2016 03:29:33 GMT
< content-type: text/html
< set-cookie: __cfduid=dafc17cc9e01e7dc926ac8617cfe4fa531470886173; expires=Fri, 11-Aug-17 03:29:33 GMT; path=/; domain=.eragano.com; HttpOnly
< x-backside-transport: OK OK
< location: https://www.eragano.com/
< x-vcap-request-id: 558316fa-7ce6-4fd3-650e-aa88d58a1dbe
< x-client-ip: 162.158.163.13
< x-global-transaction-id: 2354409361
< server: cloudflare-nginx
< cf-ray: 2d089a988c9e1123-SIN
<
{ [178 bytes data]
100   178    0   178    0     0    227      0 --:--:-- --:--:-- --:--:--   227<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx</center>
</body>
</html>

* Closing connection 0
} [5 bytes data]
* TLSv1.2 (OUT), TLS alert, Client hello (1):
} [2 bytes data]

Potential Clue

It seems CloudFlare by default (Flexible) always proxies using HTTP, even if browser is HTTPS.
While CloudFlare Full proxies using HTTPS if browser HTTPS, and using HTTP if browser is HTTP.

However, I still don't know why FORCE_HTTPS switch can't be disabled after enabled once.
With FORCE_HTTPS: false, even when accessing the mybluemix.net subdomain directly, without CloudFlare, https redirection still performed:

$ curl -v http://eragano-com.mybluemix.net
* Rebuilt URL to: http://eragano-com.mybluemix.net/
* timeout on name lookup is not supported
*   Trying 169.54.245.69...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* Connected to eragano-com.mybluemix.net (169.54.245.69) port 80 (#0)
> GET / HTTP/1.1
> Host: eragano-com.mybluemix.net
> User-Agent: curl/7.49.1
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< X-Backside-Transport: OK OK
< Connection: Keep-Alive
< Transfer-Encoding: chunked
< Content-Type: text/html
< Date: Thu, 11 Aug 2016 04:03:40 GMT
< Location: https://eragano-com.mybluemix.net/
< Server: nginx
< X-Global-Transaction-ID: 1613537793
<
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0{ [189 bytes data]
100   178    0   178    0     0    189      0 --:--:-- --:--:-- --:--:--   207<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx</center>
</body>
</html>

* Connection #0 to host eragano-com.mybluemix.net left intact

Please confirm where necessary:

  • [v] I have included a log output
  • [v] My log includes an error message
  • [v] I have included steps for reproduction

Unable to start nginx with buildpack version v1.3.3

When using the buildpack version v1.3.3. nginx is unable to start. If I instead switch back to v1.3.2 nginx starts up fine. The error which is reported in the log messages "no "events" section in configuration" was no misconfiguration, since the events section is present. My assumption is that there is a major bug in the new v1.3.3. version.

These are my log messages:

2016-03-17 09:31:44 +0000 [API] OUT App instance exited with guid c2822093-11ee-4d66-b76e-f4585
8399aad payload: {"cc_partition"=>"default", "droplet"=>"c2822093-11ee-4d66-b76e-f45858399aad", "version"=>"9f449a74-351c-4715-bb1e-2c582ff3b8ee", "instance"=>"2b9c06ab60944d31ac4442065360ff5e", "index"=>0, "reason"=>"CRASHED", "exit_status"=>1, "exit_description"=>"failed to accept connections within health check timeout", "crash_timestamp"=>1458207104}
2016-03-17 09:31:44 +0000 [DEA] ERR Instance (index 0) failed to start accepting connections
2016-03-17 09:31:44 +0000 [App/0] OUT
2016-03-17 09:31:44 +0000 [App/0] ERR 2016/03/17 09:31:44 [emerg] 31#0: no "events" section in configuration
2016-03-17 09:31:44 +0000 [App/0] ERR from /usr/bin/erb:154:in <main>' 2016-03-17 09:31:44 +0000 [App/0] ERR from /usr/bin/erb:133:inrun'
2016-03-17 09:31:44 +0000 [App/0] ERR from /usr/lib/ruby/1.9.1/erb.rb:820:in run' 2016-03-17 09:31:44 +0000 [App/0] ERR from /usr/lib/ruby/1.9.1/erb.rb:838:inresult'
2016-03-17 09:31:44 +0000 [App/0] ERR from /usr/lib/ruby/1.9.1/erb.rb:838:in eval' 2016-03-17 09:31:44 +0000 [App/0] ERR from /home/vcap/app/nginx/conf/orig.conf:52:in

'
2016-03-17 09:31:44 +0000 [App/0] ERR /home/vcap/app/nginx/conf/orig.conf:52:in `read': No such file or directory - ip-restriction.txt (Errno::ENOENT)
2016-03-17 09:31:42 +0000 [DEA] OUT Starting app instance (index 0) with guid c2822093-11ee-4d66-b76e-f45858399aad
2016-03-17 09:31:40 +0000 [STG] OUT -----> Uploading droplet (2.6M)
2016-03-17 09:31:38 +0000 [STG] OUT -----> Setting up nginx
2016-03-17 09:31:38 +0000 [STG] OUT -----> Copying project files into public/
2016-03-17 09:31:38 +0000 [STG] OUT -----> Using root folder
2016-03-17 09:31:38 +0000 [STG] OUT Downloaded [https://pivotal-buildpacks.s3.amazonaws.com/concourse-binaries/nginx/nginx-1.9.12-linux-x64.tgz]
2016-03-17 09:31:36 +0000 [STG] OUT -------> Buildpack version 1.3.3
2016-03-17 09:31:36 +0000 [STG] OUT Submodule path 'compile-extensions': checked out '9932bb1d352b88883d76df41e797a6fa556844f0'
2016-03-17 09:31:35 +0000 [STG] ERR Cloning into 'compile-extensions'...
2016-03-17 09:31:35 +0000 [STG] OUT Submodule 'compile-extensions' (https://github.com/cloudfoundry/compile-extensions.git) registered for path 'compile-extensions'
2016-03-17 09:31:32 +0000 [STG] ERR Cloning into '/tmp/buildpacks/staticfile-buildpack'...
2016-03-17 09:31:32 +0000 [STG] OUT -----> Downloaded app package (36K)
2016-03-17 09:31:32 +0000 [API] OUT Updated app with guid c2822093-11ee-4d66-b76e-f45858399aad ({"state"=>"STARTED"})
2016-03-17 09:31:31 +0000 [DEA] OUT Got staging request for app with id c2822093-11ee-4d66-b76e-f45858399aad
2016-03-17 09:31:04 +0000 [API] OUT Created app with guid c2822093-11ee-4d66-b76e-f45858399aad
2016-03-17 09:31:44 +0000 [API] OUT App instance exited with guid c2822093-11ee-4d66-b76e-f45858399aad payload: {"cc_partition"=>"default", "droplet"=>"c2822093-11ee-4d66-b76e-f45858399aad", "version"=>"9f449a74-351c-4715-bb1e-2c582ff3b8ee", "instance"=>"2b9c06ab60944d31ac4442065360ff5e", "index"=>0, "reason"=>"CRASHED", "exit_status"=>1, "exit_description"=>"failed to accept connections within health check timeout", "crash_timestamp"=>1458207104}
2016-03-17 09:31:04 +0000 [API] OUT Updated app with guid c2822093-11ee-4d66-b76e-f45858399aad ({"route"=>"7adc89a8-cb8c-4131-9d30-b622847cbac2"})

Default configuration uses an unnecessarily large amount of diskspace

Currently the staticfile-buildpack, during staging, will copy files from the declared root directory into a public/ subdirectory:

https://github.com/cloudfoundry/staticfile-buildpack/blob/master/bin/compile#L44-L49

Unless my root directory is already public/, this results in a doubling of the diskspace used by the application bits.

For example, if I have the following application:

Staticfile # specifying `public/` as my root directory
public/data # a 2MB file containing random bits

then the droplet is 4.4MB, as seen in the staging log output:

Staging complete
Uploading droplet, build artifacts cache...
Uploading droplet...
Uploading build artifacts cache...
Uploaded build artifacts cache (129B)
Uploaded droplet (4.4M)

If I have the same data file in this application:

Staticfile # not declaring a root directory
data # a 2MB file containing random bits

then the droplet is 6.3MB:

Staging complete
Uploading droplet, build artifacts cache...
Uploading droplet...
Uploading build artifacts cache...
Uploaded build artifacts cache (131B)
Uploaded droplet (6.3M)

This double-counting of application bits counts against my disk quota, which is undesired.

I don't have a proposed solution at this time, but would like to generate discussion.

pre_version latest is now 8.37

I couldn't build the vendor packages today, we're missing 8.35 from ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre

Are we ok to upgrade to 8.37?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.