chunyenHuang / hummusRecipe

A powerful PDF tool for NodeJS based on HummusJS.
https://hummus-recipe.s3.amazonaws.com/docs/Recipe.html
MIT License
339 stars 91 forks source link

Invalid ELF Header on Lambda Function #196

Open giocodebot opened 4 years ago

giocodebot commented 4 years ago

Hi! I hope you can help me, I'm trying to run it on a Lambda funtion running NodeJS 12.x but when I call it I receive the following error, thank you! image

chunyenHuang commented 4 years ago

Can you post this in muhammara as well? It seems to me it's a hummusJS related issue.

lkowalski-smartbusiness commented 4 years ago

@giocodebot I overcame the issue by creating a separate layer for the HummusRecipe + Muhammara packages and repackaging it using a LambCI docker image (clear your .node_modules beforehand):

docker run --rm -v "$PWD":/var/task lambci/lambda:build-nodejs12.x npm install
mkdir .output
docker run --rm -v "$PWD":/var/task lambci/lambda:build-nodejs12.x zip -r --symlinks .output/output.zip . -x '*.git*' -x '*.output*'

I use a separate layer to avoid tedious repackaging on every change

midnite81 commented 3 years ago

@lkowalski-smartbusiness When you say you create a seperate layer - do you mean with only the HummusRecipe + Muhammara in it, or do you mean your project as a whole and then the output.zip is uploaded as your main project on the lambda?

lkowalski-smartbusiness commented 3 years ago

@midnite81 I meant just the HummusRecipe + Muhammara but I stand corrected as there were various issues to that approach (most likely some libraries overlapping in the layer and the actual lambda function that was built the normal way, haven't had the time to investigate deeply). What I did for it to work "right here, right now" is:

I'll be following up with my findings for a proper layer with just the libraries packaged in it when I do find the time to debug it properly.

julianhille commented 1 year ago

hey, this is mostly an architecture error, like you are compiling or bundling the muhammara binary on a windows machine and then upload it to lambda. This would not work as it is a binary compiled for a specific target architecture / libc.

similar issues are here: https://github.com/julianhille/MuhammaraJS/issues/155 or here https://github.com/julianhille/MuhammaraJS/issues/154