{"id":16618403,"url":"https://github.com/andreasonny83/serverless-image-rendering","last_synced_at":"2025-03-21T14:31:32.792Z","repository":{"id":79086577,"uuid":"119206991","full_name":"andreasonny83/serverless-image-rendering","owner":"andreasonny83","description":"Image delivery with AWS Lambda :zap:","archived":false,"fork":false,"pushed_at":"2020-09-03T23:23:52.000Z","size":31727,"stargazers_count":45,"open_issues_count":4,"forks_count":19,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-18T02:12:13.182Z","etag":null,"topics":["aws-lambda","docker","lambda","nodejs","serverless"],"latest_commit_sha":null,"homepage":"https://dght5ywo5j.execute-api.us-east-1.amazonaws.com/dev/resize-image?f=placeholder.jpg\u0026w=600\u0026q=75\u0026t=webp","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andreasonny83.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-27T22:11:28.000Z","updated_at":"2024-05-02T07:46:42.000Z","dependencies_parsed_at":"2023-05-31T13:45:45.786Z","dependency_job_id":null,"html_url":"https://github.com/andreasonny83/serverless-image-rendering","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreasonny83%2Fserverless-image-rendering","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreasonny83%2Fserverless-image-rendering/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreasonny83%2Fserverless-image-rendering/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreasonny83%2Fserverless-image-rendering/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andreasonny83","download_url":"https://codeload.github.com/andreasonny83/serverless-image-rendering/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244815207,"owners_count":20514912,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws-lambda","docker","lambda","nodejs","serverless"],"created_at":"2024-10-12T02:19:50.521Z","updated_at":"2025-03-21T14:31:32.786Z","avatar_url":"https://github.com/andreasonny83.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Serverless Image Rendering\n\n\u003e Fast image delivering system using Sharp, AWS Lambda and Serverless framework.\n\n[![serverless][badge-serverless]](http://www.serverless.com)\n\nDemo Lambda function available [here](https://dght5ywo5j.execute-api.us-east-1.amazonaws.com/dev/resize-image?f=placeholder.jpg\u0026w=600\u0026q=75\u0026t=webp)\n\nMedium article available [here](https://medium.com/@andreasonny83/serverless-image-optimization-and-delivery-510b6c311fe5)\n\n- [Serverless Image Rendering](#Serverless-Image-Rendering)\n  - [Getting Started](#Getting-Started)\n    - [Prerequisites](#Prerequisites)\n  - [Optional requisites](#Optional-requisites)\n    - [Installation](#Installation)\n    - [Images Bucket](#Images-Bucket)\n  - [Usage](#Usage)\n    - [Environment configuration](#Environment-configuration)\n    - [dotENV](#dotENV)\n    - [Serving the app](#Serving-the-app)\n    - [Resizing your images](#Resizing-your-images)\n    - [Unit testing](#Unit-testing)\n    - [Docker](#Docker)\n  - [Deployment](#Deployment)\n  - [Log](#Log)\n  - [Contributing](#Contributing)\n  - [Built With](#Built-With)\n  - [License](#License)\n\n## Getting Started\n\nThese instructions will get you a copy of the project up and running on your local machine for development and testing purposes.\nSee deployment for notes on how to deploy the project on a live system.\n\n### Prerequisites\n\nThis project requires NodeJS (at least version 6) and NPM.\n[Node](http://nodejs.org/) and [NPM](https://npmjs.org/) are really easy to install.\nTo make sure you have them available on your machine,\ntry running the following command.\n\n```sh\n$ node -v \u0026\u0026 npm -v\nv10.15.1\n6.9.0\n```\n\nYou may also want to install Serverless globally on your local machine for accessing the\nCLI functionality and directly interact with your deployed Lambda function.\n\nTo install Serverless globally on your machine, run the following command\n\n```sh\n$ npm i -g serverless\n```\n\nPlease, read the [official Serverless documentation](https://serverless.com/framework/docs/getting-started/)\nto know more about the installation process.\n\nIf you want to deploy your code to AWS, then you will also need an AWS account and\n[set-up your provider credentials](https://serverless.com/framework/docs/providers/aws/guide/credentials/)\n\n## Optional requisites\n\nThis project is making use of Serverless and Docker.\nThey are both optionals however Docker will be required for deploying your local code\nto Lambda if you are not running this project from a Linux machine.\nRead the [Docker](#docker) section to know more about.\n\n### Installation\n\nStart with cloning this repo on your local machine:\n\n```sh\n$ git clone https://github.com/andreasonny83/serverless-image-rendering.git\n$ cd serverless-image-rendering\n```\n\nThen install all the Node dependencies using npm or Yarn\n\n```sh\n$ npm install\n# Or using Yarn for a faster installation\n$ yarn\n```\n\n### Images Bucket\n\nThis project is making use of a pre-existing S3 bucket from where fetching\nthe images to be processed and deliver to the client.\nIf you don't have an S3 already, create one from your AWS dashboard and\ncontinue reading the [Environment configuration](#environment-configuration)\nsection.\n\n## Usage\n\n### Environment configuration\n\nThis project contains a `serverless.sample.yml` file.\nYou need to manually renamed it to `serverless.yml`.\nIn order for your application to be correctly deployed to AWS, you will need to\nreplace the `BUCKET` name under the `environment` section according to your S3\nbucket name previously created.\n\n### dotENV\n\nFor your local development you will need a `.env` file containing your S3 bucket name.\nRename the `.env.sample` file in this project to be `.env` first, then replace the\n`your-s3-bucket-name` placeholder with the correct name of your S3 Bucket.\n\n### Serving the app\n\n```sh\n$ npm run serve\n```\n\nThis will run the Lambda function locally using `serverless-offline`.\n\n### Resizing your images\n\nWhile running your local app, open a browser to\n[`http://localhost:3000/resize-image?status`](http://localhost:3000/resize-image?status)\n\nYou should be able to see a JSON information to prove that your app is actually\nup and running.\n\nYou can then replace the `?status` endpoint with your image information.\n\n`http://localhost:3000/resize-image?f=FILE-NAME\u0026w=WIDTH\u0026h=HEIGHT\u0026q=QUALITY\u0026t=TYPE`\n\n| Query string name  | Type   | Required | Description |\n| ------------------ | ------ | -------- | ----------- |\n| `f`                | String | Yes      | The complete image name uploaded to your S3 bucket (eg. placeholder.jpg)\n| `w`                | Number | No       | The image width\n| `h`                | Number | No       | The image height\n| `q`                | Number | No       | The image quality (between 1-100)\n| `t`                | String | No       | The image type (default is webp) Available values are [webp, jpeg and png]\n\nNote. If the Type is different from your original image type, it will\nautomatically be converted into the new format.\n\n**Example**\n\n`http://localhost:3000/resize-image?f=placeholder.png\u0026w=600\u0026q=75\u0026t=jpeg`\n\nAssuming that you have an image called `placeholder.png` on your S3 bucket:\n\n\n### Unit testing\n\n```sh\n$ npm test\n```\n\nThis is using Jest framework.\nIf you want to keep running Jest in the background and watch for file change while developing\nuse the following npm command instead:\n\n```sh\n$ npm run test:watch\n```\n\n### Docker\n\nThe `Make install` command will run `npm install` from inside a Docker\ncontainer to reproduce the same environment configuration present on AWS Lambda.\nDeploying the Lambda function after running `npm install` from your local machine\nwill probably result on the function returning a server error if your local machine\nconfiguration is different from the one on AWS.\n\nTo make sure the `npm run deploy` succeeds:\n\n1. Clean your `node_modules` folder with `rm -rf node_modules package-lock.json`\n1. Create the Docker image with `make build`\n1. Run `npm install` from inside the Docker container with `make install`\n1. Then run serverless deploy` with `npm run deploy`\n\n## Deployment\n\n1. Install serverless globally\n1. Make sure you have correctly set up your AWS credentials\n1. Install the Node dependencies with Docker by running `make build` to generate\nthe Docker image, the run `make install` (This will run `npm install` from inside\nthe Docker container using the same environment setup running on AWS)\n1. run `npm run deploy` to deploy your function to AWS Lambda\n\n## Log\n\nNote. The following commands will require Serverless to be globally\ninstalled on your machine. Please read the [Prerequisites](#prerequisites)\nsection for more information.\n\nWhen your Lambda function has been deployed, you will be able to\neasily log all the events directly inside your local terminal.\n\n```sh\n$ sls logs -f {function-name} -t\n```\n\nIf you don't remember what's your function name, you can easily retrieve\nall your Lambda information running the following command from inside your\nproject's directory.\n\n```sh\n$ sls info\n```\n\n## Contributing\n\n1.  Fork it!\n2.  Create your feature branch: `git checkout -b my-new-feature`\n3.  Add your changes: `git add .`\n4.  Commit your changes: `git commit -am 'Add some feature'`\n5.  Push to the branch: `git push origin my-new-feature`\n6.  Submit a pull request :sunglasses:\n\n## Built With\n\n* VSCode\n* dotENV\n* Serverless\n* Love\n\n## License\n\n[MIT License](https://andreasonny.mit-license.org/2018-2019) © Andrea SonnY\n\n[badge-serverless]: http://public.serverless.com/badges/v3.svg\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreasonny83%2Fserverless-image-rendering","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandreasonny83%2Fserverless-image-rendering","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreasonny83%2Fserverless-image-rendering/lists"}