Reputation: 535
I'm struggling to get Neos (a php based cms) to run in a docker container for AWS Lambda. I guess I have somewhere a misunderstanding and hope anyone can help.
What I did so far:
sam local start-api
Dockerfile:
FROM bref/php-74-fpm
COPY . /var/task
# Start Bref's runtime client
CMD _HANDLER=Web/index.php /opt/bootstrap
template.yml
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
neos-demo-lambda
Sample SAM Template for neos-demo-lambda
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
Timeout: 3
Resources:
Neos:
Type: AWS::Serverless::Function
Properties:
Description: Show neos demo
PackageType: Image
ImageUri: neos7.demo.lambda.php74:latest
#Handler: "Web/index.php /opt/bootstrap"
#Handler: "Web/index.php"
MemorySize: 1024
Timeout: 360
Environment:
Variables:
FLOW_CONTEXT: 'Production'
FLOW_PATH_TEMPORARY_BASE: '/tmp/neos'
FLOW_PATH_DATA_BASE: '/tmp/Data'
BREF_AUTOLOAD_PATH: '/var/task/Packages/Libraries/autoload.php'
AWS_S3_BUCKET_STORAGE: 'neos-lambda-demo-private'
AWS_S3_BUCKET_TARGET: 'neos-lambda-demo-public'
AWS_CLOUDFRONT_BASE_URI: ''
AWS_REDIS_HOST: ''
Events:
htmlHttpApi:
Type: HttpApi
TimeoutInMillis: 28000
Metadata:
DockerTag: neos7.lambda.demo
DockerContext: ./Web/index.php
Dockerfile: Dockerfile
Response of sam local start-api
:
entrypoint requires the handler name to be the first argument
time="2021-04-14T22:11:48.093" level=error msg="Init failed" InvokeID= error="Runtime exited with error: exit status 142"
time="2021-04-14T22:11:48.093" level=error msg="INIT DONE failed: Runtime.ExitError"
Invalid lambda response received: Lambda response must be valid json
2021-04-15 00:11:48 127.0.0.1 - - [15/Apr/2021 00:11:48] "GET / HTTP/1.1" 502 -
What I don't understand, I'd expect that there is always a valid json returned, even though the php delivers a 5xx error. I'm lost ... even though this wouldn't be the case, how can I debug the issue?
In the end, I have to create my own docker image as Neos is too big to use the bref layers and I need quite some php extensions. If I could understand the current issue, I can work through this and provide a working container for everyone.
I have a few more questions, in this scenario, were I have a web application and use a container, do I have to install the bref packages with composer? That wasn't clear in the blog post. Also do I have to set the Handler in serverless/sam and if so, which would be the correct string, given that Web/index.php
is the path in Neos?
In general, Neos would work awesome in AWS. My setup would be:
As soon as this is working, I'll publish all information for free for the Neos community to get this working.
Hope someone can help...
Thank you!
Upvotes: 0
Views: 959
Reputation: 49693
Could you try this:
FROM bref/php-74-fpm
# Include any extension you want, for example:
#COPY --from=bref/extra-gd-php-74:0.9.5 /opt /opt
ADD . $LAMBDA_TASK_ROOT
CMD [ "index.php" ]
The format has been simplified since the article (see https://gist.github.com/mnapoli/f911a50c7aab77690e6cdde157812265).
Upvotes: 3