Coder Social home page Coder Social logo

andrebrinkop / image-resizer-microservice Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 491 KB

Image Resizer is a simple microservice providing an HTTP Rest API to resize images. The project includes a CI/CD Pipeline and CloudFormation templates to operationalize this microservice.

JavaScript 56.68% Makefile 1.15% Dockerfile 3.28% Shell 38.89%

image-resizer-microservice's Introduction

Image Resizer Microservice

This project contains a simple microservice to resize images and the necessary CI/CD Pipeline and Infrastructure as Code (CloudFormation) templates to completely automtically operationalize this microservice. The provided automation scripts can easily be adapted to work with other services as well.

Screenshot showing the Microservice in action using Postman

Project Overview

This project contains a Node.js microservice that allows users to resize images using an HTTP Post endpoint.
It contains the source code to the Node.JS app and all the necessary files and scripts to operationalize the Microservice using an automated CI/CD Pipeline implemented in Jenkins that builds a Docker image and deploys an AWS EKS (Kubernetes) cluster that will be used to run the Docker container.

The CI/CD Pipeline takes care of the following steps:

  1. Checkout SCM
  2. Setup: Installing necessary dependencies of the Node.js app
  3. Linting: Analyze the JavaScript code and the Dockerfile for potential errors
  4. Testing: Run integration tests on the Node.js app
  5. Build image: Deploy the Node.js app inside a Docker image
  6. Upload image: Upload the created image to Docker Hub
  7. Create/Update EKS Cluster: Create respectively update the EKS Cluster and the connected AWS infrastructure using CloudFormation templates
  8. Deploy Container to EKS: Deploy the Docker container to the EKS Cluster using kubectl

Image Resizer Microservice

The app is providing endpoints that can be used to resize image and to retrieve size information from uploaded images.
The processing of images is done by using sharp(https://github.com/lovell/sharp) and can easily be extended to include additional functionalities.

The implemented app provides the following endpoints:

POST /image-details

Description:
Returns the format and the size information (width and height) for the provided image.

Parameters:
* image: image file

Responses:
* 200 - successful operation:
  {
        name: string
        format: string,
        width: integer,
        height: integer
  }
* 400 - invalid request: request body does not contain an image
* 422 - invalid request content: the provided file is not supported
POST /resize-image

Description:
Resizes a provided image to the specified dimensions.
If the specified dimensions do have a different aspect ratio as the original picture letterboxing
is being used to prevent the image from being clinched/streteched.

Parameters:
* image: image file
* height: integer (desired height in px)
* width: integer (desired width in px)

Responses:
* 200 - successful operation: returns the provided image file adjusted to the desired size
* 400 - invalid request: request body does not contain an image
* 422 - invalid request content: the provided file is not supported

Repository Content

  • src/ contains the code for the Image Resizer Node.js app
  • test/ contains the integration tests for the Image Resizer Node.js app
  • cloudformation/ contains CloudFormation templates to create a network and an EKS cluster on top of that network as well as scripts to automatically create/update/delete stacks using those templates
  • kubernetes/ contains the kubectl config as well as a script to automatically deploy the application to the EKS cluster

Setup the Environment

  • Install Node.js and npm
  • Run make install to install the necessary dependencies

Running

  1. Standalone: make run
  2. Docker: docker build --tag=image-resizer . && docker run -p 80:3000 image-resizer

image-resizer-microservice's People

Contributors

andrebrinkop avatar dependabot[bot] avatar

Watchers

James Cloos avatar  avatar

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.