Skip to content

Commit 3a11ae2

Browse files
committed
Version 1
1 parent e1b09be commit 3a11ae2

File tree

11 files changed

+1193
-1
lines changed

11 files changed

+1193
-1
lines changed
File renamed without changes.

NOTICE renamed to NOTICE.txt

File renamed without changes.

README.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,37 @@
1-
# serverless-image-handler
1+
# AWS Serverless Image Handler Lambda wrapper for Thumbor
22
A solution to dynamically handle images on the fly, utilizing Thumbor (thumbor.org)
3+
4+
## OS/Python Environment Setup
5+
```bash
6+
sudo yum-config-manager --enable epel
7+
sudo yum update -y
8+
sudo yum install git libpng-devel libcurl-devel gcc python-devel libjpeg-devel -y
9+
sudo pip install --upgrade pip
10+
alias sudo='sudo env PATH=$PATH'
11+
sudo pip install --upgrade setuptools
12+
sudo pip install --upgrade virtualenv
13+
```
14+
15+
## Building Lambda Package
16+
```bash
17+
cd deployment
18+
./build-s3-dist.sh source-bucket-base-name
19+
```
20+
source-bucket-base-name should be the base name for the S3 bucket location where the template will source the Lambda code from.
21+
The template will append '-[region_name]' to this value.
22+
For example: ./build-s3-dist.sh solutions
23+
The template will then expect the source code to be located in the solutions-[region_name] bucket
24+
25+
## CF template and Lambda function
26+
Located in deployment/dist
27+
28+
29+
***
30+
31+
Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
32+
33+
Licensed under the Amazon Software License (the "License"). You may not use this file except in compliance with the License. A copy of the License is located at
34+
35+
http://aws.amazon.com/asl/
36+
37+
or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions and limitations under the License.

deployment/build-s3-dist.sh

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/bin/bash
2+
3+
# This assumes all of the OS-level configuration has been completed and git repo has already been cloned
4+
#sudo yum-config-manager --enable epel
5+
#sudo yum update -y
6+
#sudo yum install git libpng-devel libcurl-devel gcc python-devel libjpeg-devel -y
7+
#sudo pip install --upgrade pip
8+
#alias sudo='sudo env PATH=$PATH'
9+
#sudo pip install --upgrade setuptools
10+
#sudo pip install --upgrade virtualenv
11+
12+
# This script should be run from the repo's deployment directory
13+
# cd deployment
14+
# ./build-s3-dist.sh source-bucket-base-name
15+
# source-bucket-base-name should be the base name for the S3 bucket location where the template will source the Lambda code from.
16+
# The template will append '-[region_name]' to this bucket name.
17+
# For example: ./build-s3-dist.sh solutions
18+
# The template will then expect the source code to be located in the solutions-[region_name] bucket
19+
20+
# Check to see if input has been provided:
21+
if [ -z "$1" ]; then
22+
echo "Please provide the base source bucket name where the lambda code will eventually reside.\nFor example: ./build-s3-dist.sh solutions"
23+
exit 1
24+
fi
25+
26+
# Build source
27+
echo "Staring to build distribution"
28+
echo "mkdir -p dist"
29+
mkdir -p dist
30+
echo "cp -f serverless-image-handler.template dist"
31+
cp -f serverless-image-handler.template dist
32+
echo "Updating code source bucket in template with $1"
33+
replace="s/%%BUCKET_NAME%%/$1/g"
34+
echo "sed -i '' -e $replace dist/serverless-image-handler.template"
35+
sed -i '' -e $replace dist/serverless-image-handler.template
36+
cd dist
37+
pwd
38+
echo "virtualenv env"
39+
virtualenv env
40+
echo "source env/bin/activate"
41+
source env/bin/activate
42+
cd ../..
43+
pwd
44+
echo "pip install source/. --target=$VIRTUAL_ENV/lib/python2.7/site-packages/"
45+
pip install source/. --target=$VIRTUAL_ENV/lib/python2.7/site-packages/
46+
echo "pip install -r source/requirements.txt --target=$VIRTUAL_ENV/lib/python2.7/site-packages/"
47+
pip install -r source/requirements.txt --target=$VIRTUAL_ENV/lib/python2.7/site-packages/
48+
cd $VIRTUAL_ENV
49+
pwd
50+
echo "git clone git://github.com/pornel/pngquant.git pngquant_s"
51+
git clone git://github.com/pornel/pngquant.git pngquant_s
52+
cd pngquant_s
53+
pwd
54+
echo "./configure --enable-static --disable-shared"
55+
./configure --enable-static --disable-shared
56+
echo "make"
57+
make
58+
echo "cp pngquant $VIRTUAL_ENV"
59+
cp -f pngquant $VIRTUAL_ENV
60+
cd $VIRTUAL_ENV/lib/python2.7/site-packages
61+
pwd
62+
echo "zip -q -r9 $VIRTUAL_ENV/../serverless-image-handler.zip *"
63+
zip -q -r9 $VIRTUAL_ENV/../serverless-image-handler.zip *
64+
cd $VIRTUAL_ENV
65+
pwd
66+
echo "zip -q -g $VIRTUAL_ENV/../serverless-image-handler.zip pngquant"
67+
zip -q -g $VIRTUAL_ENV/../serverless-image-handler.zip pngquant
68+
cd ..
69+
echo zip -d serverless-image-handler.zip botocore*
70+
zip -q -d serverless-image-handler.zip pip*
71+
zip -q -d serverless-image-handler.zip easy*
72+
echo "Clean up build material"
73+
rm -rf $VIRTUAL_ENV
74+
echo "Completed building distribution"

0 commit comments

Comments
 (0)