Skip to content

feat: add amazon-linux-2 versions #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
*.zip
layer
layer
.DS_Store
__pycache__
22 changes: 17 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,28 @@ AWS Lambda layer with GraphicsMagick binaries.
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):

```
arn:aws:lambda:eu-west-1:175033217214:layer:graphicsmagick:2
arn:aws:lambda:eu-west-1:175033217214:layer:graphicsmagick-amzn2:1
```

![Provide layer ARN](img/usage.png "Provide layer ARN screenshot")

## Version ARNs
## Version ARNs for Amazon Linux 2 Runtimes

| GraphicsMagick version | ARN |
| --- | --- |
| 1.3.31 | `arn:aws:lambda:<region>:175033217214:layer:graphicsmagick:2` |
| GraphicsMagick version | ARN |
| ---------------------- | ------------------------------------------------------------------- |
| 1.3.35 | `arn:aws:lambda:<region>:175033217214:layer:graphicsmagick-amzn2:1` |

## Version ARNs for Amazon Linux Runtimes

| GraphicsMagick version | ARN |
| ---------------------- | ------------------------------------------------------------------ |
| 1.3.35 | `arn:aws:lambda:<region>:175033217214:layer:graphicsmagick-amzn:1` |

## Version ARNs for Legacy Runtimes

| GraphicsMagick version | ARN |
| ---------------------- | ------------------------------------------------------------- |
| 1.3.31 | `arn:aws:lambda:<region>:175033217214:layer:graphicsmagick:2` |

## Available Regions

Expand Down
29 changes: 25 additions & 4 deletions Dockerfile → amazon-linux-2/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,33 @@
FROM lambci/lambda-base:build
FROM amazonlinux:2

RUN yum update -y

RUN yum install -y libpng-devel libjpeg-devel libtiff-devel libuuid-devel gcc
RUN yum install -y \
make \
gcc \
zip \
tar \
gzip \
file \
lcms2 \
libSM \
libXext \
freetype \
bzip2-devel \
libpng-devel \
libjpeg-devel \
libtiff-devel \
libuuid-devel \
freetype-devel \
liblcms2-devel

RUN curl -O http://mirror.centos.org/altarch/7/os/aarch64/Packages/urw-fonts-2.4-16.el7.noarch.rpm && \
rpm -ivh --nodeps urw-fonts-2.4-16.el7.noarch.rpm

ARG GM_VERSION

RUN curl https://versaweb.dl.sourceforge.net/project/graphicsmagick/graphicsmagick/${GM_VERSION}/GraphicsMagick-${GM_VERSION}.tar.xz | tar -xJ && \
RUN curl -O -L https://versaweb.dl.sourceforge.net/project/graphicsmagick/graphicsmagick/${GM_VERSION}/GraphicsMagick-${GM_VERSION}.tar.gz && \
tar -xvf GraphicsMagick-${GM_VERSION}.tar.gz && \
cd GraphicsMagick-${GM_VERSION} && \
./configure --prefix=/opt --enable-shared=no --enable-static=yes --with-gs-font-dir=/opt/share/fonts/default/Type1 && \
make && \
Expand All @@ -27,7 +48,7 @@ RUN cp /usr/lib64/liblcms2.so* /opt/lib && \
cp /usr/lib64/libjbig.so* /opt/lib && \
cp /usr/lib64/libxcb.so* /opt/lib && \
cp /usr/lib64/libXau.so* /opt/lib && \
cp /usr/lib64/libuuid.so /opt/lib/libuuid.so.1 && \
cp /usr/lib64/libuuid.so /opt/lib/libuuid.so.1 && \
cp /usr/lib64/libbz2.so /opt/lib/libbz2.so.1

RUN mkdir -p /opt/share/fonts/default && \
Expand Down
2 changes: 1 addition & 1 deletion build.sh → amazon-linux-2/build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

export GM_VERSION=1.3.31
export GM_VERSION=1.3.35

docker build --build-arg GM_VERSION -t gm-lambda-layer .
docker run --rm gm-lambda-layer cat /tmp/gm-${GM_VERSION}.zip > ./layer.zip
32 changes: 32 additions & 0 deletions amazon-linux-2/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

GM_VERSION=1.3.35
LAYER_NAME='graphicsmagick-amzn2'

REGIONS='
ap-northeast-1
ap-northeast-2
ap-south-1
ap-southeast-1
ap-southeast-2
ca-central-1
eu-north-1
eu-central-1
eu-west-1
eu-west-2
eu-west-3
sa-east-1
us-east-1
us-east-2
us-west-1
us-west-2
'

PROFILE='dev'

for region in $REGIONS; do
aws lambda add-layer-version-permission --region $region --layer-name $LAYER_NAME \
--statement-id sid1 --action lambda:GetLayerVersion --principal '*' \
--version-number $(aws lambda publish-layer-version --region $region --layer-name $LAYER_NAME --zip-file fileb://layer.zip \
--description "GraphicsMagick ${GM_VERSION} binaries for AmazonLinux2" --query Version --output text --profile $PROFILE) --profile $PROFILE
done
15 changes: 15 additions & 0 deletions amazon-linux-2/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
rm -rf layer && unzip layer.zip -d layer

cd test

docker run -i --rm \
-v "$PWD":/var/task \
-v "$PWD"/../layer:/opt \
lambci/lambda:nodejs12.x \
index.handler

docker run -i --rm \
-v "$PWD":/var/task \
-v "$PWD"/../layer:/opt \
lambci/lambda:python3.7 \
main.handler
File renamed without changes
13 changes: 13 additions & 0 deletions amazon-linux-2/test/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const { execSync } = require('child_process')

exports.handler = async (event) => {
execSync('ls -al /opt/share/fonts/default/Type1', { encoding: 'utf8', stdio: 'inherit' })

execSync('gm version', { encoding: 'utf8', stdio: 'inherit' })

execSync('gm convert -list formats', { encoding: 'utf8', stdio: 'inherit' })

execSync('gm convert -list fonts', { encoding: 'utf8', stdio: 'inherit' })

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' })
}
File renamed without changes.
60 changes: 60 additions & 0 deletions amazon-linux/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
FROM amazonlinux:1

RUN yum update -y

RUN yum install -y \
make \
gcc \
zip \
tar \
gzip \
file \
lcms2 \
libSM \
libXext \
freetype \
findutils \
bzip2-devel \
libpng-devel \
libjpeg-devel \
libtiff-devel \
libuuid-devel \
freetype-devel \
liblcms2-devel

RUN curl -O http://mirror.centos.org/altarch/7/os/aarch64/Packages/urw-fonts-2.4-16.el7.noarch.rpm && \
rpm -ivh --nodeps urw-fonts-2.4-16.el7.noarch.rpm

ARG GM_VERSION

RUN curl -O -L https://versaweb.dl.sourceforge.net/project/graphicsmagick/graphicsmagick/${GM_VERSION}/GraphicsMagick-${GM_VERSION}.tar.gz && \
tar -xvf GraphicsMagick-${GM_VERSION}.tar.gz && \
cd GraphicsMagick-${GM_VERSION} && \
./configure --prefix=/opt --enable-shared=no --enable-static=yes --with-gs-font-dir=/opt/share/fonts/default/Type1 && \
make && \
make install

RUN cp /usr/lib64/liblcms2.so* /opt/lib && \
cp /usr/lib64/libtiff.so* /opt/lib && \
cp /usr/lib64/libfreetype.so* /opt/lib && \
cp /usr/lib64/libjpeg.so* /opt/lib && \
cp /usr/lib64/libpng*.so* /opt/lib && \
cp /usr/lib64/libXext.so* /opt/lib && \
cp /usr/lib64/libSM.so* /opt/lib && \
cp /usr/lib64/libICE.so* /opt/lib && \
cp /usr/lib64/libX11.so* /opt/lib && \
cp /usr/lib64/liblzma.so* /opt/lib && \
cp /usr/lib64/libxml2.so* /opt/lib && \
cp /usr/lib64/libgomp.so* /opt/lib && \
cp /usr/lib64/libjbig.so* /opt/lib && \
cp /usr/lib64/libxcb.so* /opt/lib && \
cp /usr/lib64/libXau.so* /opt/lib && \
cp /usr/lib64/libuuid.so /opt/lib/libuuid.so.1 && \
cp /usr/lib64/libbz2.so /opt/lib/libbz2.so.1

RUN mkdir -p /opt/share/fonts/default && \
cp -R /usr/share/fonts/default/Type1 /opt/share/fonts/default/Type1

RUN cd /opt && \
find . ! -perm -o=r -exec chmod +400 {} \; && \
zip -yr /tmp/gm-${GM_VERSION}.zip ./*
6 changes: 6 additions & 0 deletions amazon-linux/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

export GM_VERSION=1.3.35

docker build --build-arg GM_VERSION -t gm-lambda-layer .
docker run --rm gm-lambda-layer cat /tmp/gm-${GM_VERSION}.zip > ./layer.zip
6 changes: 3 additions & 3 deletions publish.sh → amazon-linux/publish.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

GM_VERSION=1.3.31
LAYER_NAME='graphicsmagick'
GM_VERSION=1.3.35
LAYER_NAME='graphicsmagick-amzn'

REGIONS='
ap-northeast-1
Expand All @@ -28,5 +28,5 @@ for region in $REGIONS; do
aws lambda add-layer-version-permission --region $region --layer-name $LAYER_NAME \
--statement-id sid1 --action lambda:GetLayerVersion --principal '*' \
--version-number $(aws lambda publish-layer-version --region $region --layer-name $LAYER_NAME --zip-file fileb://layer.zip \
--description "GraphicsMagick ${GM_VERSION} binaries" --query Version --output text --profile $PROFILE) --profile $PROFILE
--description "GraphicsMagick ${GM_VERSION} binaries for AmazonLinux" --query Version --output text --profile $PROFILE) --profile $PROFILE
done
File renamed without changes.
Binary file added amazon-linux/test/image1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
7 changes: 7 additions & 0 deletions amazon-linux/test/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import os

def handler (event, context):
os.system("gm version")
os.system("gm convert -list formats")
os.system("gm convert -list fonts")
return os.system('gm convert -font Courier -fill white -draw "rotate 20 text 10,10 Hello-World" image1.jpg /tmp/gm-test-output.jpg')