Giter Club home page Giter Club logo

kagebunshin's Introduction

ARCHITECTURE EXPLANATION

USAGE

Prepare an S3 bucket (srcBucket) where you will upload the images, and another different S3 bucket (dstBucket) to where new images will be resized and copied over.

Create/update an env.yml file in the root directory, copy and paste the content of env.sample.yml in it, and fill up the respective values.

Install docker. The purpose of docker is to install the correct image cropping binary for the lamdba node 8.10 environment that lambda uses instead of that of your local machine.

When running the deployment script, it will install the docker image prior to uploading to lambda.

Time to deploy!

DEPLOYMENT

To deploy to AWS using named profile:

npm run deploy

DEVELOPMENT

This project is meant to be plug and play. In the event you need something more than what is set up, you can develop and debug.

Run npm run installsharp to cleanly install the correct sharp for your local machine.

Before you start development, create a pair of src and dst buckets for development purpose. Upload an image in your src bucket. This is because during development, the copying of files from src bucket to dst will be executed on the AWS.

In the event.json file, replace <BUCKET_NAME> with your src bucket name and <PATH_TO_IMAGE> with the path to the image in the src bucket. The json inside event.json follows the exact JSON structure of a S3 put event.

Then run this command to debug:

npm run installsharp # ensures installs binary
sls invoke local -f onUpload -p event.json

The first command will download the sharp folder that fits your local machine. It can be skipped if you have run it at least once after your lattest deploy to production.

The second command will call the onUpload function using the content in event.json as the event param.

FEATURES

In the env.yml file, append widths that you want to crop the image according to to the widths variable, separated by comma. Follow the syntax as shown in env.sample.yml file.

Uses sharp to resize and produce produce extra image of the webp format. This will require lambda to have the correct binary. That is easily installed with the sharp package with npm and easily uploaded to lambda using docker.

TODOs

  • code in a way that can use other cloud providers

kagebunshin's People

Contributors

kusakusakusa avatar

Watchers

 avatar  avatar

Forkers

thegoodypet

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.