diff --git a/README.md b/README.md index 737fae44..93e41344 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,10 @@ The classic PHP configuration is used as fallback when no framework was detected This is also used when an `index.php` file was found in the root of your project and no `composer.json`. +### Bedrock + +Is used when the `extra.heroku.framework` key is set to `bedrock` in the `composer.json`. + ### Magento Is used when the `extra.heroku.framework` key is set to `magento` in the `composer.json`. diff --git a/conf/nginx/bedrock.conf.erb b/conf/nginx/bedrock.conf.erb new file mode 100644 index 00000000..76f790bf --- /dev/null +++ b/conf/nginx/bedrock.conf.erb @@ -0,0 +1,26 @@ +root /app/<%= ENV['DOCUMENT_ROOT'] %>; + +fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; +index index.php index.html; + +location / { + try_files $uri $uri/ /index.php?$query_string; +} + +location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|ttf|woff)$ { + access_log off; +} + +# Prevent access to dot files +location ~ /\. { + return 404; +} + +# allow all php files +# should probably whitelist specific php files +location ~ \.php { + include fastcgi_params; + fastcgi_pass php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_buffers 256 4k; +} diff --git a/frameworks/bedrock b/frameworks/bedrock new file mode 100755 index 00000000..9c200437 --- /dev/null +++ b/frameworks/bedrock @@ -0,0 +1,29 @@ +#!/bin/bash + +BUILD_DIR="$2" +basedir="$( cd -P "$( dirname "$0" )" && pwd )" + +function sets_framework_bedrock() { + [ $(jq --raw-output '.extra.heroku.framework' < "$BUILD_DIR/composer.json") == "bedrock" ] +} + +case "$1" in + detect) + if [ ! -f "$BUILD_DIR/composer.json" ]; then + exit 1 + fi + + if sets_framework_bedrock; then + echo "-----> Detected Bedrock WordPress app" + exit 0 + else + exit 1 + fi + ;; + compile) + echo "-----> Setting up Bedrock WordPress app" + cp "$basedir/../conf/nginx/bedrock.conf.erb" "$BUILD_DIR/conf/site.conf.erb" + mkdir -p $BUILD_DIR/web/app/uploads + chmod a+w -R $BUILD_DIR/web/app/uploads + ;; +esac