bref v2 docker container does not properly accept POST input
aknosis opened this issue · 3 comments
aknosis commented
Description:
I spun up a new project with bref v2, when using the docker info from here, I can’t seem to get it to read any POST data ($_POST and php://input are always empty). For a sanity check I redid everything with v1 and didn’t have any issues.
How to reproduce:
composer init
composer require bref/bref:^2.0@beta
./vendor/bin/bref init
(choose Web application)
docker-compose:
(8.1 and 8.2 exhibit same behavior)
version: "3.5"
services:
app:
image: bref/php-82-fpm-dev:2
ports: [ '8000:8000' ]
volumes:
- .:/var/task
environment:
HANDLER: index.php
docker-compose up
2023-03-01T03:48:11.766731159Z 01 Mar 2023 03:48:11,764 [INFO] (rapid) exec '/var/runtime/bootstrap' (cwd=/var/task, handler=)
2023-03-01T03:48:13.001214724Z ⚡️ Server is running at http://localhost:8000
2023-03-01T03:48:17.758301451Z 01 Mar 2023 03:48:17,757 [INFO] (rapid) extensionsDisabledByLayer(/opt/disable-extensions-jwigqn8j) -> stat /opt/disable-extensions-jwigqn8j: no such file or directory
2023-03-01T03:48:17.758334744Z 01 Mar 2023 03:48:17,757 [WARNING] (rapid) Cannot list external agents error=open /opt/extensions: no such file or directory
2023-03-01T03:48:17.758713178Z START RequestId: 8dd01c10-b6d4-4e8a-a5f4-e59f1081350b Version: $LATEST
2023-03-01T03:48:18.409674374Z [01-Mar-2023 03:48:18] NOTICE: fpm is running, pid 31
2023-03-01T03:48:18.409692325Z [01-Mar-2023 03:48:18] NOTICE: ready to handle connections
2023-03-01T03:48:18.484529603Z END RequestId: 8dd01c10-b6d4-4e8a-a5f4-e59f1081350b
2023-03-01T03:48:18.484551424Z REPORT RequestId: 8dd01c10-b6d4-4e8a-a5f4-e59f1081350b Init Duration: 0.49 ms Duration: 726.00 ms Billed Duration: 727 ms Memory Size: 3008 MB Max Memory Used: 3008 MB
2023-03-01T03:51:14.041644317Z START RequestId: fe57f0f0-e5d1-4dde-8d9d-e1eb01c38124 Version: $LATEST
2023-03-01T03:51:14.057204662Z END RequestId: fe57f0f0-e5d1-4dde-8d9d-e1eb01c38124
2023-03-01T03:51:14.057288146Z REPORT RequestId: fe57f0f0-e5d1-4dde-8d9d-e1eb01c38124 Duration: 15.54 ms Billed Duration: 16 ms Memory Size: 3008 MB Max Memory Used: 3008 MB
index.php:
<?php
var_dump($_POST);
var_dump(file_get_contents('php://input'));
var_dump($_SERVER);
Output of POST to localhost:8000
array(0) {
}
string(0) ""
array(57) {
["HOSTNAME"]=>
string(12) "314f399aa5fa"
["AWS_LAMBDA_FUNCTION_VERSION"]=>
string(7) "$LATEST"
["AWS_SESSION_TOKEN"]=>
string(0) ""
["PHP_INI_SCAN_DIR"]=>
string(25) ":/var/task/php/conf.dev.d"
["AWS_LAMBDA_LOG_GROUP_NAME"]=>
string(21) "/aws/lambda/Functions"
["LD_LIBRARY_PATH"]=>
string(94) "/var/lang/lib:/lib64:/usr/lib64:/var/runtime:/var/runtime/lib:/var/task:/var/task/lib:/opt/lib"
["LAMBDA_TASK_ROOT"]=>
string(9) "/var/task"
["AWS_LAMBDA_LOG_STREAM_NAME"]=>
string(7) "$LATEST"
["AWS_LAMBDA_RUNTIME_API"]=>
string(14) "127.0.0.1:9001"
["HANDLER"]=>
string(9) "index.php"
["AWS_LAMBDA_FUNCTION_NAME"]=>
string(13) "test_function"
["PATH"]=>
string(52) "/var/lang/bin:/usr/local/bin:/usr/bin/:/bin:/opt/bin"
["_"]=>
string(12) "/opt/bin/php"
["PWD"]=>
string(9) "/var/task"
["AWS_SECRET_ACCESS_KEY"]=>
string(0) ""
["LAMBDA_RUNTIME_DIR"]=>
string(12) "/var/runtime"
["LANG"]=>
string(11) "en_US.UTF-8"
["TZ"]=>
string(15) ":/etc/localtime"
["AWS_ACCESS_KEY_ID"]=>
string(0) ""
["SHLVL"]=>
string(1) "2"
["HOME"]=>
string(1) "/"
["_HANDLER"]=>
string(9) "index.php"
["RUNTIME_CLASS"]=>
string(20) "Bref\FpmRuntime\Main"
["AWS_LAMBDA_FUNCTION_MEMORY_SIZE"]=>
string(4) "3008"
["USER"]=>
string(6) "nobody"
["CONTENT_LENGTH"]=>
string(1) "0"
["CONTENT_TYPE"]=>
string(80) "multipart/form-data; boundary=--------------------------926422385474604171512351"
["SERVER_PROTOCOL"]=>
string(8) "HTTP/1.1"
["SERVER_NAME"]=>
string(14) "localhost:8000"
["SERVER_PORT"]=>
string(2) "80"
["SERVER_ADDR"]=>
string(9) "127.0.0.1"
["REMOTE_PORT"]=>
string(2) "80"
["REMOTE_ADDR"]=>
string(9) "127.0.0.1"
["SERVER_SOFTWARE"]=>
string(4) "bref"
["SCRIPT_FILENAME"]=>
string(19) "/var/task/index.php"
["REQUEST_URI"]=>
string(1) "/"
["REQUEST_METHOD"]=>
string(4) "POST"
["GATEWAY_INTERFACE"]=>
string(11) "FastCGI/1.0"
["HTTP_CONTENT_LENGTH"]=>
string(3) "161"
["HTTP_CONTENT_TYPE"]=>
string(80) "multipart/form-data; boundary=--------------------------926422385474604171512351"
["HTTP_CONNECTION"]=>
string(10) "keep-alive"
["HTTP_ACCEPT_ENCODING"]=>
string(17) "gzip, deflate, br"
["HTTP_HOST"]=>
string(14) "localhost:8000"
["HTTP_POSTMAN_TOKEN"]=>
string(36) "8b9192d8-3d44-49e6-b857-86fb27725cb2"
["HTTP_CACHE_CONTROL"]=>
string(8) "no-cache"
["HTTP_ACCEPT"]=>
string(3) "*/*"
["HTTP_USER_AGENT"]=>
string(21) "PostmanRuntime/7.30.0"
["LAMBDA_REQUEST_CONTEXT"]=>
string(329)
"{"http":{"method":"POST","path":"\/","protocol":"http","sourceIp":"::ffff:172.23.0.1","userAgent":"PostmanRuntime\/7.30.0"},"accountId":"123456789012","apiId":"api-id","domainName":"localhost","domainPrefix":"","requestId":"id","routeKey":"$default","stage":"$default","time":"2023-02-27T15:19:14.936Z","timeEpoch":1677511154936}"
["LAMBDA_INVOCATION_CONTEXT"]=>
string(179)
"{"awsRequestId":"1b62cfe1-f560-4a03-a037-fe237968de7f","deadlineMs":1677511454939,"invokedFunctionArn":"arn:aws:lambda:us-east-1:012345678912:function:test_function","traceId":""}"
["QUERY_STRING"]=>
string(0) ""
["PATH_INFO"]=>
string(1) "/"
["FCGI_ROLE"]=>
string(9) "RESPONDER"
["PHP_SELF"]=>
string(1) "/"
["REQUEST_TIME_FLOAT"]=>
float(1677511154.942073)
["REQUEST_TIME"]=>
int(1677511154)
["argv"]=>
array(0) {
}
["argc"]=>
int(0)
}
mnapoli commented
Reopening until I finish publishing all the docker images
mnapoli commented
Fixed!
Don't forget to pull the latest images to get the fix.
Thanks for the reproducible example and the details, really appreciated you took the time!
aknosis commented
Tested and confirmed fixed, Thanks!