Created
October 9, 2020 20:26
-
-
Save CacheControl/bc1542f85d79d12df6387172283312c4 to your computer and use it in GitHub Desktop.
dockerfile for bundling graphicsmagick within a lambda
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM amazonlinux | |
# epel-release required for graphicsmagick | |
RUN amazon-linux-extras install epel | |
RUN yum -y --nogpgcheck install gcc-c++ make GraphicsMagick yum-utils rpmdevtools | |
# node.js 12 (also adds npm) | |
RUN curl -sL https://rpm.nodesource.com/setup_12.x | bash - | |
RUN yum -y --nogpgcheck install nodejs | |
WORKDIR /tmp/graphicsmagick-build | |
RUN yum -y install gcc-c++ libpng-devel libjpeg-devel libtiff-devel wget | |
RUN wget https://downloads.sourceforge.net/project/graphicsmagick/graphicsmagick/1.3.35/GraphicsMagick-1.3.35.tar.gz | |
RUN tar zxvf GraphicsMagick-1.3.35.tar.gz | |
RUN ./GraphicsMagick-1.3.35/configure --prefix=/tmp/graphicsmagick --enable-shared=no --enable-static=yes | |
RUN make && make install | |
RUN cp /usr/lib64/liblcms2.so* /tmp/graphicsmagick/lib && \ | |
cp /usr/lib64/libjpeg.so* /tmp/graphicsmagick/lib && \ | |
cp /usr/lib64/libgomp.so* /tmp/graphicsmagick/lib && \ | |
cp /usr/lib64/libpng*.so* /tmp/graphicsmagick/lib && \ | |
cp /usr/lib64/libtiff.so* /tmp/graphicsmagick/lib && \ | |
cp /usr/lib64/libfreetype.so* /tmp/graphicsmagick/lib && \ | |
cp /usr/lib64/libXext.so* /tmp/graphicsmagick/lib && \ | |
cp /usr/lib64/libSM.so* /tmp/graphicsmagick/lib && \ | |
cp /usr/lib64/libICE.so* /tmp/graphicsmagick/lib && \ | |
cp /usr/lib64/libX11.so* /tmp/graphicsmagick/lib && \ | |
cp /usr/lib64/liblzma.so* /tmp/graphicsmagick/lib && \ | |
cp /usr/lib64/libxml2.so* /tmp/graphicsmagick/lib && \ | |
cp /usr/lib64/libjbig.so* /tmp/graphicsmagick/lib && \ | |
cp /usr/lib64/libxcb.so* /tmp/graphicsmagick/lib && \ | |
cp /usr/lib64/libXau.so* /tmp/graphicsmagick/lib | |
# add node.js code and graphicsmagic files to lambda folder | |
WORKDIR /var/origin-response | |
RUN mv /tmp/graphicsmagick /var/origin-response | |
# add node.js code | |
ADD ./origin-response . | |
RUN npm install --production && rm -rf test/ | |
# generate lambda zip (quietly, high compression). output filesize to keep tabs on lambda@edge limit of 50mb | |
RUN zip -q -r9 origin-response.zip * && du -h origin-response.zip | |
# upload zip to aws | |
# initial gm using the appPath parameter (outside handler): | |
# const appPath = process.env.LAMBDA_TASK_ROOT ? `${process.env.LAMBDA_TASK_ROOT}/graphicsmagick/bin/` : undefined; | |
# const gm = require('gm').subClass({ appPath }); | |
# finally, don't forget to add the following lines within the lambda handler: | |
# | |
# process.env.PATH = `${process.env.PATH}:${appPath}`; | |
# process.env.LD_LIBRARY_PATH = `${process.env.LAMBDA_TASK_ROOT}/graphicsmagick/lib`; | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment