Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Bedrock WordPress apps #134

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
20 changes: 20 additions & 0 deletions conf/nginx/bedrock.conf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
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;
}
location /. {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the goal of preventing the access to the url /. ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry these should not have been part or the pull request - I should move them into another branch for my personal use. I forgot that all the changes I made to master would be added to the previous pull request.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The /. should have been ~ /. to block dotfiles. I guess as it was it blocked access to a folder named period in the root, which was dumb.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

be careful to escape the dot in regexes though

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I had it escaped in my comment - but it must have been removed by the parser. Commit e57ea4b has the correctly escaped regex version.

return 404;
}
location ~ \.php {
include fastcgi_params;
fastcgi_pass php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_buffers 256 4k;
}
2 changes: 1 addition & 1 deletion conf/php/php-fpm.conf
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ pm = static
; forget to tweak pm.* to fit your needs.
; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
; Note: This value is mandatory.
pm.max_children = 8
pm.max_children = 3
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why changing this ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was something i should have done in a branch to save memory on the my server that has many apps running on only 4 cores. I committed a revert of this for master.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am using this with dokku on a server with ~10 apps and the memory usage is a bit much with 8 php processes per app - epecially since I do not have 8 cores. I have moved this customization into another branch.


; The number of child processes created on startup.
; Note: Used only when pm is set to 'dynamic'
Expand Down
29 changes: 29 additions & 0 deletions frameworks/bedrock
Original file line number Diff line number Diff line change
@@ -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