适用于AWS Lambda的节点画布构建 [英] node-canvas build for AWS Lambda

查看:97
本文介绍了适用于AWS Lambda的节点画布构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Linux&节点菜鸟.我正在尝试在AWS Lambda中运行FabricJS(需要节点画布).我已经能够按照说明在AWS Linux EC2上启动和运行,但是Lambda尽我所能.任何人都有关于如何为AW Lambda编译此文件的提示或指示?

I'm a Linux & node noob. I'm trying to run FabricJS (which requires node-canvas) in AWS Lambda. I've been able to follow the instructions to get up and running on an AWS Linux EC2, however, Lambda has me at my wits end. Anyone have any tips or pointers on how to get this compiled for AW Lambda?

推荐答案

我在

I found this issue in the Node Canvas GitHub site. The questioner was trying to run FabricJS in Lambda as well. Here is the relevant section with an answer:

  1. 确保您在lambda当前使用的同一AMI上进行编译: http://docs.aws.amazon.com/lambda/latest/dg/current-supported-versions.html

  1. Make sure you're compiling this on the same AMI that lambda currently uses: http://docs.aws.amazon.com/lambda/latest/dg/current-supported-versions.html

Lambda在/var/task(解压缩时的路径)上运行,因此something.so在zip文件的根目录将在/var/task/something.so.

Lambda runs at /var/task (that's the path when you unzip), so something.so at the root of the zip file will be at /var/task/something.so.

然后,我们要使用"rpath"构建我们的库:

We then want to build our libraries using an "rpath":

   export LDFLAGS=-Wl,-rpath=/var/task/

  1. 根据以下条件编译库: https://github.com/Automattic/node-canvas/wiki/Installation---Amazon-Linux-AMI-%28EC2%29
  1. Compile libraries according to: https://github.com/Automattic/node-canvas/wiki/Installation---Amazon-Linux-AMI-%28EC2%29

您可能希望将prefix =〜/canvas设置为将所有文件放在一个位置.

You may want to set the prefix= ~/canvas to have all the files in one place.

  1. 使用npm安装节点画布

  1. Install node-canvas with npm

cd node_modules/canvas; node-gyp重建

cd node_modules/canvas; node-gyp rebuild

mkdir〜/pkg并在其中cp .so文件(〜/canvas/lib/*.so),使用-L取消引用符号链接.

mkdir ~/pkg and cp the .so files (~/canvas/lib/*.so) there, using -L to dereference symlinks.

将pkg目录保存到本地lambda文件夹,可能会将文件放在正确的位置. (.so在根目录下,node_modules/canvas与其他库一起).您可能需要重新安排.

scp the pkg directory to the local lambda folder, possibly putting the files in the right places. (.so in root, node_modules/canvas with other libs). You'll probably want to rearrange this.

这篇关于适用于AWS Lambda的节点画布构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆