Skip to content

Commit db9ff78

Browse files
authored
Merge pull request rpidanny#2 from rpidanny/lib-fix
Fix missing shared libraries Closes rpidanny#1
2 parents 1b7206c + 9320324 commit db9ff78

File tree

7 files changed

+60
-5
lines changed

7 files changed

+60
-5
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
*.zip
1+
*.zip
2+
layer

Dockerfile

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,37 @@ FROM lambci/lambda-base:build
22

33
RUN yum update -y
44

5-
RUN yum install -y libpng-devel libjpeg-devel libtiff-devel gcc
5+
RUN yum install -y libpng-devel libjpeg-devel libtiff-devel libuuid-devel gcc
66

77
ARG GM_VERSION
88

99
RUN curl https://versaweb.dl.sourceforge.net/project/graphicsmagick/graphicsmagick/${GM_VERSION}/GraphicsMagick-${GM_VERSION}.tar.xz | tar -xJ && \
1010
cd GraphicsMagick-${GM_VERSION} && \
11-
./configure --prefix=/opt --enable-shared=no --enable-static=yes && \
11+
./configure --prefix=/opt --enable-shared=no --enable-static=yes --with-gs-font-dir=/opt/share/fonts/default/Type1 && \
1212
make && \
1313
make install
1414

15+
RUN cp /usr/lib64/liblcms2.so* /opt/lib && \
16+
cp /usr/lib64/libtiff.so* /opt/lib && \
17+
cp /usr/lib64/libfreetype.so* /opt/lib && \
18+
cp /usr/lib64/libjpeg.so* /opt/lib && \
19+
cp /usr/lib64/libpng*.so* /opt/lib && \
20+
cp /usr/lib64/libXext.so* /opt/lib && \
21+
cp /usr/lib64/libSM.so* /opt/lib && \
22+
cp /usr/lib64/libICE.so* /opt/lib && \
23+
cp /usr/lib64/libX11.so* /opt/lib && \
24+
cp /usr/lib64/liblzma.so* /opt/lib && \
25+
cp /usr/lib64/libxml2.so* /opt/lib && \
26+
cp /usr/lib64/libgomp.so* /opt/lib && \
27+
cp /usr/lib64/libjbig.so* /opt/lib && \
28+
cp /usr/lib64/libxcb.so* /opt/lib && \
29+
cp /usr/lib64/libXau.so* /opt/lib && \
30+
cp /usr/lib64/libuuid.so /opt/lib/libuuid.so.1 && \
31+
cp /usr/lib64/libbz2.so /opt/lib/libbz2.so.1
32+
33+
RUN mkdir -p /opt/share/fonts/default && \
34+
cp -R /usr/share/fonts/default/Type1 /opt/share/fonts/default/Type1
35+
1536
RUN cd /opt && \
1637
find . ! -perm -o=r -exec chmod +400 {} \; && \
1738
zip -yr /tmp/gm-${GM_VERSION}.zip ./*

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ AWS Lambda layer with GraphicsMagick binaries.
77
Click on Layers and choose `Add a layer`, and `Provide a layer version ARN` and enter the following ARN (replace eu-west-1 with the region of your Lambda):
88

99
```
10-
arn:aws:lambda:eu-west-1:175033217214:layer:graphicsmagick:1
10+
arn:aws:lambda:eu-west-1:175033217214:layer:graphicsmagick:2
1111
```
1212

1313
![Provide layer ARN](img/usage.png "Provide layer ARN screenshot")
@@ -16,7 +16,7 @@ arn:aws:lambda:eu-west-1:175033217214:layer:graphicsmagick:1
1616

1717
| GraphicsMagick version | ARN |
1818
| --- | --- |
19-
| 1.3.31 | `arn:aws:lambda:<region>:175033217214:layer:graphicsmagick:1` |
19+
| 1.3.31 | `arn:aws:lambda:<region>:175033217214:layer:graphicsmagick:2` |
2020

2121
## Available Regions
2222

test.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
rm -rf layer && unzip layer.zip -d layer
2+
3+
cd test
4+
5+
docker run -i --rm \
6+
-v "$PWD":/var/task \
7+
-v "$PWD"/../layer:/opt \
8+
lambci/lambda:nodejs10.x \
9+
index.handler
10+
11+
docker run -i --rm \
12+
-v "$PWD":/var/task \
13+
-v "$PWD"/../layer:/opt \
14+
lambci/lambda:python3.7 \
15+
main.handler

test/image1.jpg

36.8 KB
Loading

test/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const { execSync } = require('child_process')
2+
3+
exports.handler = async (event) => {
4+
execSync('gm version', { encoding: 'utf8', stdio: 'inherit' })
5+
6+
execSync('gm convert -list formats', { encoding: 'utf8', stdio: 'inherit' })
7+
8+
execSync('gm convert -list fonts', { encoding: 'utf8', stdio: 'inherit' })
9+
10+
execSync('gm convert -font Courier -fill white -draw "rotate 20 text 10,10 Hello-World" image1.jpg /tmp/gm-test-output.jpg', { encoding: 'utf8', stdio: 'inherit' })
11+
}

test/main.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import os
2+
3+
def handler (event, context):
4+
os.system("gm version")
5+
os.system("gm convert -list formats")
6+
os.system("gm convert -list fonts")
7+
return os.system('gm convert -font Courier -fill white -draw "rotate 20 text 10,10 Hello-World" image1.jpg /tmp/gm-test-output.jpg')

0 commit comments

Comments
 (0)