我启动了最新的aws linux并运行了以下命令。
yum -y install gcc-c++ libpng-devel libjpeg-devel libtiff-devel wgetwget https://downloads.sourceforge.net/project/graphicsmagick/graphicsmagick/1.3.26/GraphicsMagick-1.3.26.tar.gztar zxvf GraphicsMagick-1.3.26.tar.gzcd GraphicsMagick-1.3.26./configure --prefix=/var/task/graphicsmagick --enable-shared=no --enable-static=yesmakesudo make installtar zcvf ~/graphicsmagick.tgz /var/task/graphicsmagick/
我将目录下放到本地,然后将其放入要压缩和部署的软件包中。我的布局类似于链接的aws repo代码,但针对无服务器进行了修改。
Lambda代码:
// graphicsmagick dir is at the root of my projectconst BIN_PATH = process.env['LAMBDA_TASK_ROOT'] + "/graphicsmagick/bin/";const Gm = require('gm').subClass({ appPath: BIN_PATH });// below is inside the handlerprocess.env['PATH'] = process.env['PATH'] + ':' + BIN_PATH;无服务器
package: artifact: /path/to/function.zip
我使用工件并构建自己的zip。如果您遇到以下问题,建议您这样做。
https://github.com/serverless/serverless/issues/3215
# -y to keep the symlinks and thus reduce the size from 266M to 73Mcd lambda && zip -FS -q -r -y ../dist/function.zip *
来自以下方面的想法:
https://gist.github.com/bensie/56f51bc33d4a55e2fc9a
https://github.com/awslabs/serverless-image-
resizing
编辑:可能还想签出lambda图层。可能只需要做一次这种事情。



