-
Notifications
You must be signed in to change notification settings - Fork 147
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
PHP-FPM options via environment variables #394
base: main
Are you sure you want to change the base?
PHP-FPM options via environment variables #394
Conversation
There is a way to set document root for app engine using this buildpack via app.yaml, but we also need this ability outside app engine. So the solution here is to allow setting it via NGINX_DOCUMENT_ROOT environment variable.
Looks good to me. |
@@ -194,3 +194,18 @@ func IsPresentAndTrue(varName string) (bool, error) { | |||
|
|||
return parsed, nil | |||
} | |||
|
|||
// IsPresentAndInt returns true and the integer value if the environment variable evaluates exists and contains an integer. | |||
func IsPresentAndInt(varName string) (bool, int, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: not a big deal, but I would simplify this to return 2 values instead of 3:
func GetIfInt(varName string) (int, bool) {
...
}
We lost the error indication, but simplify things a bit. Your call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest, I initially wrote it this way then backtracked, as everywhere else is very heavy on catching the errors & throwing them properly, so I didn't want to implement something that would silently fail (and revert to the default) if someone makes a mistake in the environment variable and it doesn't parse properly.
I'm happy either way though - if someone from Google can weigh in on which one you'd be more likely to accept for merge, I'll make it so.
How did you test this? Not sure if the acceptance test framework is ready for this configuration. @kennethye1 any idea how to test this? In general, how do we build the builder image so we can test manually? (I haven't done that before since I relied on the acceptance test for past contribution) |
I haven't been able to test this so far, as I'm not sure how. And likewise, I couldn't see any existing tests that could be used as a template to evaluate the output for the Any guidance would be greatly appreciated. |
I believe our |
Thanks @kennethye1 for the pointer. Tried to follow CONTRIBUTING.md but it doesn't work:
Not a problem to solve currently (maybe just outdated doc?), because I did some trial and error and found that So I was able to test manually that this PR works as intended this way: https://github.com/sonnysasaka/buildpack-demo/blob/c702b475f6583db3d07e3b8b64f474eea001d28e/build.sh, except that this PR change is missing a dependency @iamacarpet:
@iamacarpet please add the missing dependency, and if @kennethye1 is fine with the code I support this change and have verified manually that it works as intended. |
Thanks so much for helping me navigate the testing & the bazel dependencies @sonnysasaka . Agree with your call on the function name, thanks for pointing it out! That should all be in the latest change - thanks for all the help everyone. Might want to squash merge this one after I've had to add the additional commits - sorry about that! |
overall LGTM from me and verified working. I recommend squashing the changes into 2 commits (one authored by me about the document root and another one by @iamacarpet about the FPM configs + some refactor). @kennethye1 to weigh in. |
a0eed2e
to
836a66d
Compare
Very good point @sonnysasaka , you can tell my mind is busy on other things, shame on me! Thanks for pointing this out - I've squashed my own commits into a single commit, keeping your commit first. |
IMO it seems like we are adding a lot of environment variables vs having the user provide their own php-fpm file. |
@kennethye1 I understand that it's almost as easy to just provide the php-fpm.conf. How about the "document root" one? Currently there is no easy way to configure this, without replacing the whole nginx.conf which is hard for user. Are you okay with adding NGINX_DOCUMENT_ROOT env var (also part of this PR and originally from #390) |
From the conversation we've had in #392 , here is a replacement change for configuring
php-fpm
via environment variables, e.g.:Based on @sonnysasaka 's branch for adding
NGINX_DOCUMENT_ROOT
, as I think it's important they go together.@sonnysasaka @sl0wik are you both happier with this one?
And @jama22 @kennethye1 , would you be happy to merge this if the other two are happy please?
Regards,
iamacarpet