1212# This script should be run from the repo's deployment directory
1313# cd deployment
1414# ./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.
15+ # source-bucket-base-name should be the base name for the S3 bucket location where the template will source the Lambda code from.
1616# The template will append '-[region_name]' to this bucket name.
1717# For example: ./build-s3-dist.sh solutions
1818# The template will then expect the source code to be located in the solutions-[region_name] bucket
2525
2626# Build source
2727echo " Staring to build distribution"
28+ echo " export deployment_dir=` pwd` "
29+ export deployment_dir=` pwd`
2830echo " mkdir -p dist"
2931mkdir -p dist
3032echo " cp -f serverless-image-handler.template dist"
@@ -33,18 +35,37 @@ echo "Updating code source bucket in template with $1"
3335replace=" s/%%BUCKET_NAME%%/$1 /g"
3436echo " sed -i '' -e $replace dist/serverless-image-handler.template"
3537sed -i ' ' -e $replace dist/serverless-image-handler.template
36- cd dist
38+ echo " Creating UI ZIP file"
39+ cd $deployment_dir /../source/ui
40+ zip -q -r9 $deployment_dir /dist/serverless-image-handler-ui.zip *
41+ echo " Building custom resource package ZIP file"
42+ cd $deployment_dir /dist
43+ pwd
44+ echo " virtualenv env"
45+ virtualenv env
46+ echo " source env/bin/activate"
47+ source env/bin/activate
48+ echo " pip install $deployment_dir /../source/image-handler-custom-resource/. --target=$deployment_dir /dist/env/lib/python2.7/site-packages/"
49+ pip install $deployment_dir /../source/image-handler-custom-resource/. --target=$deployment_dir /dist/env/lib/python2.7/site-packages/
50+ cd $deployment_dir /dist/env/lib/python2.7/site-packages/
51+ zip -r9 $deployment_dir /dist/serverless-image-handler-custom-resource.zip *
52+ cd $deployment_dir /dist
53+ zip -q -d serverless-image-handler-custom-resource.zip pip*
54+ zip -q -d serverless-image-handler-custom-resource.zip easy*
55+ rm -rf env
56+ echo " Building Image Handler package ZIP file"
57+ cd $deployment_dir /dist
3758pwd
3859echo " virtualenv env"
3960virtualenv env
4061echo " source env/bin/activate"
4162source env/bin/activate
4263cd ../..
4364pwd
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/
65+ echo " pip install source/image-handler/ . --target=$VIRTUAL_ENV /lib/python2.7/site-packages/"
66+ pip install source/image-handler/ . --target=$VIRTUAL_ENV /lib/python2.7/site-packages/
67+ echo " pip install -r source/image-handler/ requirements.txt --target=$VIRTUAL_ENV /lib/python2.7/site-packages/"
68+ pip install -r source/image-handler/ requirements.txt --target=$VIRTUAL_ENV /lib/python2.7/site-packages/
4869cd $VIRTUAL_ENV
4970pwd
5071echo " git clone git://github.com/pornel/pngquant.git pngquant_s"
6687echo " zip -q -g $VIRTUAL_ENV /../serverless-image-handler.zip pngquant"
6788zip -q -g $VIRTUAL_ENV /../serverless-image-handler.zip pngquant
6889cd ..
69- echo zip -d serverless-image-handler.zip botocore*
7090zip -q -d serverless-image-handler.zip pip*
7191zip -q -d serverless-image-handler.zip easy*
7292echo " Clean up build material"
0 commit comments