Skip to content

Commit 089b653

Browse files
authored
Merge pull request #36 from venveo/feature/layers
Switch to using Lambda Layers
2 parents 3f5cafd + 2c33cb8 commit 089b653

File tree

1,496 files changed

+259195
-168
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,496 files changed

+259195
-168
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
.idea
44
.nyc_output/
55
coverage
6-
node_modules
6+
/node_modules/*
77
.env
88
# package directories
99
jspm_packages

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## Unreleased
88

9+
### Changed
10+
- Sharp is now bundled as its own layer, removing the need for swapping between platforms for local development
11+
912
### Added
1013
- Added support for `ar` param, allowing an aspect ratio (16:9) to be supplied
1114

README.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
# Serverless Sharp Image Processor
2-
A solution to dynamically optimize and transform images on the fly, utilizing [Sharp](https://sharp.pixelplumbing.com/en/stable/).
2+
A solution to dynamically optimize and transform images on the fly, utilizing [Sharp](https://sharp.pixelplumbing.com/en/stable/) and AWS Lambda.
33

44
## Who is this for?
5-
This software is for people who want to optimize and transform (crop, scale, convert, etc) images from an existing S3
5+
This software is for people who want to optimize and run basic transformations (crop, scale, convert, etc) on images from an existing S3
66
bucket without running computationally expensive processes or servers or paying for expensive third-party services.
77

8+
Serverless Sharp is written to be a drop-in replacement for most essential features of Imgix and costs magnitudes less for
9+
most users.
10+
811
## How does it work?
912
After deploying this solution, you'll find yourself with a number of AWS resources (all priced based on usage rather
1013
than monthly cost). The most important of which are:
@@ -24,6 +27,10 @@ For example: `mybucket/images`
2427
- `SECURITY_KEY` See security section
2528
- `SLS_IGNORE` A comma-delineated string of paths that should be ignored (for example, `favicon.ico`)
2629

30+
You can define multiple environments, each of which will inherit your default settings. This is useful if you have
31+
different buckets for staging & production, for example. You may also wish to create an environment without a sign-key
32+
for local development.
33+
2734
## API & Usage
2835
We chose to base our API around the [Imgix service](https://docs.imgix.com/apis/url) to allow for backwards compatibility
2936
with the already popular service. The idea is that all CMS plugins should be able to seamlessly use this service in-place of
@@ -120,14 +127,9 @@ This package uses Serverless to allow for local development by simulating API Ga
120127
5. Run `serverless offline`
121128

122129
## Deploying to AWS
123-
First, we need to procure sharp/libvips binaries compiled for Amazon Linux. We can do this by running the following:
124-
125-
```
126-
npm run sharp:linux
127-
```
128-
129-
This will remove any existing Sharp binaries and then reinstall them with Linux x64 in mind.
130-
131-
Ensure your `settings.yml` file is properly configured as shown in the previous steps
130+
Ensure your `settings.yml` file is properly configured as shown in the previous steps.
132131

133132
Run: `serverless deploy [--stage=dev] [--settings=settings.yml]`
133+
134+
If you need to deploy using a specific AWS profile, you should run:
135+
`AWS_SDK_LOAD_CONFIG=true serverless deploy [--stage=dev] [--settings=settings.yml] --aws-profile PROFILE_NAME `

lambdaLayers/SharpLayer/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
1. docker run --rm -v "$PWD":/var/task lambci/lambda:build-nodejs10.x npm install sharp
2+
2. Copy new node_modules into nodejs folder
3+
3. In a temporary directory, run `npm install --no-cache --arch=x64 --platform=linux --target=8.10.0 sharp`
4+
4. Locate libvips.so.42.xx.x and libvips-cpp.so.xx.x and copy to lib folder
211 KB
Binary file not shown.
3.95 MB
Binary file not shown.

lambdaLayers/SharpLayer/nodejs/node_modules/.bin/detect-libc

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lambdaLayers/SharpLayer/nodejs/node_modules/.bin/mkdirp

Lines changed: 33 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lambdaLayers/SharpLayer/nodejs/node_modules/.bin/prebuild-install

Lines changed: 85 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lambdaLayers/SharpLayer/nodejs/node_modules/.bin/rc

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)