commit 070274df7323cdfd891d1a8d3c948a3d83f9dea4 Author: rhy-jot Date: Fri Aug 16 23:41:19 2013 -0700 Initial version diff --git a/README.md b/README.md new file mode 100644 index 0000000..1d727e2 --- /dev/null +++ b/README.md @@ -0,0 +1,20 @@ +# NGINX Buildpack + +**Note**: This has only been tested with [dokku](https://github.com/progrium/dokku) - it may not work elsewhere. + +## Structure +* .nginx - File: its presence signals that this buildpack should be used +* www - Folder: holds all files to be served by nginx +* nginx.conf.erb - Optional File: overrides `conf/nginx.conf.erb` +* mime.types - Optional File: overrides `conf/mime.types` + + +## License (MIT) + +Copyright (C) 2013 rhy-jot + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/bin/compile b/bin/compile new file mode 100644 index 0000000..82302ab --- /dev/null +++ b/bin/compile @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +set -e + +apt-get update +apt-get -y install nginx + +BINDIR=$(dirname "$0") + +if [[ ! -f $1/nginx.conf.erb ]]; then + cp $BINDIR/../conf/nginx.conf.erb $1/nginx.conf.erb +fi + +if [[ ! -f $1/mime.types ]]; then + cp $BINDIR/../conf/mime.types $1/mime.types +fi diff --git a/bin/detect b/bin/detect new file mode 100644 index 0000000..ce643f6 --- /dev/null +++ b/bin/detect @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +set -e + +if [[ -f $1/.nginx ]]; then + echo "nginx" + exit 0 +else + exit 1 +fi diff --git a/bin/release b/bin/release new file mode 100644 index 0000000..9c398ef --- /dev/null +++ b/bin/release @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +set -e + +cat << EOF +--- +default_process_types: + web: erb $1/nginx.conf.erb > $1/nginx.conf && nginx -c /app/nginx.conf +EOF diff --git a/conf/mime.types b/conf/mime.types new file mode 100644 index 0000000..25ae94e --- /dev/null +++ b/conf/mime.types @@ -0,0 +1,48 @@ +types { + text/html html htm shtml; + text/css css; + text/xml xml rss; + image/gif gif; + image/jpeg jpeg jpg; + application/x-javascript js; + text/plain txt; + text/x-component htc; + text/mathml mml; + image/png png; + image/x-icon ico; + image/x-jng jng; + image/vnd.wap.wbmp wbmp; + application/java-archive jar war ear; + application/mac-binhex40 hqx; + application/pdf pdf; + application/x-cocoa cco; + application/x-java-archive-diff jardiff; + application/x-java-jnlp-file jnlp; + application/x-makeself run; + application/x-perl pl pm; + application/x-pilot prc pdb; + application/x-rar-compressed rar; + application/x-redhat-package-manager rpm; + application/x-sea sea; + application/x-shockwave-flash swf; + application/x-stuffit sit; + application/x-tcl tcl tk; + application/x-x509-ca-cert der pem crt; + application/x-xpinstall xpi; + application/zip zip; + application/octet-stream deb; + application/octet-stream bin exe dll; + application/octet-stream dmg; + application/octet-stream eot; + application/octet-stream iso img; + application/octet-stream msi msp msm; + audio/mpeg mp3; + audio/x-realaudio ra; + video/mpeg mpeg mpg; + video/quicktime mov; + video/x-flv flv; + video/x-msvideo avi; + video/x-ms-wmv wmv; + video/x-ms-asf asx asf; + video/x-mng mng; +} diff --git a/conf/nginx.conf.erb b/conf/nginx.conf.erb new file mode 100644 index 0000000..ea87722 --- /dev/null +++ b/conf/nginx.conf.erb @@ -0,0 +1,18 @@ +worker_processes 1; +error_log error.log; +pid nginx.pid; +daemon off; + +events { + worker_connections 768; +} + +http { + include mime.types; + server { + listen <%= ENV['PORT'] %>; + server_name _; + root /app/www; + index index.html; + } +}