Sign inSign up

kennyhyun/nodejs-s3-thumbnail-generator

By kennyhyun

•Updated over 5 years ago

Image
0

257

kennyhyun/nodejs-s3-thumbnail-generator repository overview

⁠nodejs-s3-thumbnail-generator

A CDN solution using AWS S3 and Lambda

prod system

dev system

This is still in progress

⁠Goal

  • Provide Prod solution via Amazon Marketplace
  • Provide Dev environment same as prod environment (from the view point of frontend and thumbnail generator)

Check the dev console in action!

network

⁠Starting local development environment with docker-compose

Since there is no ssl certificate, you will need to ignore (by-pass) the certificate error. (Click Advanced and Proceed to ...)

Minio s3 endpoint is https://localhost/ or http://localhost:9000.

Use key id and credential from the .env file

AKIAMOCKACESSKEYIDZZ
mock+AWS+SECRETaccessKEY+mock+access+KEY

from the sample

⁠make the Minio bucket public

image

From the three dots icon beside the bucket, click Edit policy and click add button.

image

and then try https://localhost/images/3wm604wp7qg21.jpg⁠

⁠Using docker-compose

If you want to use the s3 endpoint to your docker-compose project, use docker network.

your-service:
  ...
  network: traefik
networks:
  traefik:
    external:
      name: traefik

Then you can access the bucket via http://minio:9000/⁠ from your container.

⁠Generator API

  • Use Sharp library
    • use stream to download and upload the images
  • On the fly generation with the width and/or height provided
  • The generator Lambda can be customised and updated

⁠Duplicate external url

/images/any/external/file.jpg?duplicate=<url> will download url and save to images/any/external/file.jpg

only jpegs and pngs extensions are supported.

Since this is mutating the source bucket, this endpoint should be authenticated (TODO)

⁠traefik dashboard

http://localhost:8081⁠

⁠TODOs

  • Dev env
    • docker-compose with traefik
    • minio
    • nginx with 307 redirect
    • serverless offline generator in docker
      • ${width}x${height}
      • x${height}
      • ${width}x
    • duplicate external images
    • authenticate duplication
  • Prod env
    • cloudformation

Tag summary

Content type

Image

Digest

Size

110 MB

Last updated

over 5 years ago

docker pull kennyhyun/nodejs-s3-thumbnail-generator