Git Product home page Git Product logo

exercise-3's Introduction

Exercise 3 for Cloud Computing

Summer Semester 2024

For more enquiries, please contact me

Dear students,

Welcome to the third exercise for Cloud Computing. Now that you are experts on Docker Compose, we are gonna explore building microservices (kind of, the idea still holds).

During this assignment, you will explore the requirements of minimalizing your containers for deploying microservices! You will also explore using a Load Balancer to orchestrate traffic accross different endpoints.

As previous assignments, we will build on top of your existing code, which you will partition into smaller to generate five different containers. So, what is the task?

The challenge

To succeed in this assignment, you must do the following:

  1. Use Docker Compose to orchestrate your five containers and deploy NGINX to control the traffic between your services based on the request method. The containers are as follows:
    • A container to handle each operation for /api/books: GET, POST, PUT, and DELETE
    • A container to handle requests to /*, i.e., the rendering of the webpage.
    • A container for NGINX.
  2. Use a Multi-stage Dockerfile to minimize the size of the image.
  3. Publish to a public container registry (e.g., Docker Hub) your images.

Requirements and Test Scenarios

Requirements

  • You must create all images for x86_64 (i.e., amd64).
  • You must use a DB: you can run it as a container or install it directly in your VM.
  • Create unique code-bases to handle each operation (GET, POST, PUT, DELETE, and server-side rendering) by decoupling the current code structure.
  • The URI for MongoDB must be given via an environment variable.
  • The traffic must be redirected via NGINX by checking the request's method.
  • Do not modify the headers inserted by NGINX.
  • The automated tests from Exercise 1 must pass.

Tests

  1. Using an insolated MongoDB instance, the submission server will download, configure, and run all of your images. (10 pts).
  2. Using the isolated instance, the submission server will perform tests to the different available endpoints (45 pts).
  3. Using your VM, the submission server will perform tests with the given endpoint and check that you are running NGINX with proper configuration (45 pts). Please make sure the port in the given port matches the exposed one for NGINX.

What do you need for this assignment?

The starting point is the code from your last exercise and your existing Docker Compose file. From there, you will have to expand such file to include:

  • The configuration for NGINX. NGINX can be configured using an nginx.conf file that you must pass to the respective container by mounting a volume into the respective path. Please look at this tutorial by Digitial Ocean, which explains the structure of the file. Since we want to redirect based on request's methods, this page could provide insightful information on how to configure your $location. Hint
  • Configure your other services to start in a timely manner so they are reachable once NGINX is up.
  • Use MongoDB to run before everything starts.

Extra options to explore

Since we are looking to optimize the size of a microservice's container, it might be useful to explore multi-stage builds to reduce the size of the final container. You can read more here on how to create a multi-stage build.

Basically, we want you to first build your executable: download necessary packages, compile your code, and deploy on a thinner container. Given the multi-stage containers, you can copy the compiled code (and necessary dependencies) from a previous stage to the current one (a smaller one). Usually, people use an alpine version of linux to deploy lightweight containers. That means, you build your code using the current heavy- weight Golang container, you copy the final binary, and the required files (for rendering HTML) into the smaller stage, which generates a tiny image perfect for microservices.

If you want to improve your code even more and remove file dependencies, Golang provides a neat feature called go-embed to compile a given folder into the final binary to remove dependencies with the host filesystem. Since I cannot check whether you are using such feature, I leave it to you to explore!

Happy Coding!

exercise-3's People

Watchers

Ali Azimi 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.