zoellner / sharp-heic-lambda-layer

Lambda Layer providing sharp with HEIC support
MIT License
68 stars 66 forks source link

Build lambda layer for ARM64 architecture #11

Open alex-vladut opened 2 years ago

alex-vladut commented 2 years ago

Do you have any suggestion on how the Makefile could be updated to build the Lambda Layer for Amazon's ARM64 architecture? I tried changing these lines (as advised on sharp's docs):

- LD_LIBRARY_PATH=$(PREFIX_PATH)/lib npm --prefix "$(ARTIFACTS_DIR)/nodejs/" install sharp@$(SHARP_VERSION)
+ SHARP_IGNORE_GLOBAL_LIBVIPS=1 LD_LIBRARY_PATH=$(PREFIX_PATH)/lib npm --prefix "$(ARTIFACTS_DIR)/nodejs/" install --arch=arm64 --platform=linux sharp@$(SHARP_VERSION)
- ldd $(ARTIFACTS_DIR)/nodejs/node_modules/sharp/build/Release/sharp-linux-x64.node | sed -nE "s/^[^\/\n]*(\/[^ ]+)(.*)/\1/p" | xargs cp -t $(ARTIFACTS_DIR)/lib
+ ldd $(ARTIFACTS_DIR)/nodejs/node_modules/sharp/build/Release/sharp-linux-arm64v8.node | sed -nE "s/^[^\/\n]*(\/[^ ]+)(.*)/\1/p" | xargs cp -t $(ARTIFACTS_DIR)/lib

The ldd command is now returning an error that sharp-linux-arm64v8.node is not a dynamic executable, which I suspect is due to the fact it was build for a different architecture than the one it is currently running on. I would be curious if anyone tried this and if you have any suggestion on how that could be solved. Thanks!

zoellner commented 2 years ago

I'm not using arm64 architecture myself yet, so can't comment on this