Code Monkey home page Code Monkey logo

prodev-composed-services's Introduction

Compose Some Microservices!

In this exercise, you're going to use docker-compose to provision and manage some microservices. There are two dynamic services, one static service, and a service that hosts MongoDB.

service map

Fork this application to your own repository. That will be what you submit.

Please read this entire file before starting.

Composing the applications

Each of the services has some Dockerfile in it that you will use for your docker-compose file.

It would be illustrative for you to examine the different Dockerfiles so that you can see the different things each does.

A MongoDB container for credentials

Here are the requirements for a MongoDB container in your docker-compose file:

  • The name of the service that holds the MongoDB must be mongodb
  • Use the mongo:4-bionic image from hub.docker.com
  • Mount the /data/db directory in the container to the local ./auth/data directory on your file system (this will let MongoDB get access to any previously created data)

The authorization app

Here are requirements for the authorization app in your docker-compose file:

  • The name of the service must be auth
  • Use the Dockerfile.dev file in ./auth to build the service's image
  • You must define the two following environment variables:
    • JWT_SECRET must be some string value that will be used to sign and validate the authorization bearer tokens
    • MONGODB_URL must be the valid MongoDB URL for your MongoDB container, such as mongodb://mongodb/prodev-composed-auth

The to-do item app

Here are requirements for the todo app in your docker-compose file:

  • The name of the service must be app
  • Use the Dockerfile.dev file in ./app to build the service's image
  • Mount the following volumes for the container:
    • ./app/data:/usr/src/app/data
    • ./app/src:/usr/src/app/src

The front-end

The front-end is based on an NGINX image and is the only one for which you need to map the ports for access. It also acts as a reverse proxy for the authentication and todo services. Here are the requirements for the front-end in your docker-compose file:

  • Use the Dockerfile file in ./ghi to build the service's image
  • Map port 80 in the container to the port 8910
  • Mount the /usr/share/nginx/html directory in the container to the local ./ghi/static directory on your file system

Some helpful commands

Sometimes you'll want to remove all of the containers that docker-compose has built so that you can get a clean build. To do that, run

docker-compose rm -f

If you want to get a really clean point, run the following command from the root of this repository.

for image in `docker image ls | grep "$(basename $(pwd))_" | awk -s '{ print $1; }'`                                                                                              
do
  docker image rm $image
done

This will remove all of the images and force another build from the "ground up".

You're done when...

You can run the application from http://localhost:8910.

Once you're done, submit your repository's URL in the learning management system.

prodev-composed-services's People

Watchers

James Cloos 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.