Coder Social home page Coder Social logo

hello-microservices's Introduction

Installation

$ npm install

Running the app

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

Running in docker

0. Remove all existing containers

Container name can be one of: redis | rabbit | lorem | math | human | hello

$ docker stop <container name>
$ docker rm <container name>

1. First of all build images

$ docker build -f .\app.Dockerfile -t <your name>/hello-microservice .
$ docker build -f .\human-generator.Dockerfile -t <your name>/human-generator .
$ docker build -f .\lorem-ipsum-world.Dockerfile -t <your name>/lorem-ipsum-world .
$ docker build -f .\math-world.Dockerfile -t <your name>/math-world .

2. Create network

$ docker network create hello

3. Run Redis and RabbitMQ in docker

NOTE: Pull Redis and RabbitMQ images to local docker pull redis and docker pull rabbitmq if you don't.

$ docker run -itd -p 6379:6379 --network hello --name redis -h redis redis
$ docker run -itd -p 5672:5672 --network hello --name rabbit -h rabbit rabbitmq

4. Run microservices

NOTE: All microservices are using .dev.env and corresponding to redis/rabbit/math docker container names

$ docker run --network hello -itd --name human -h human <your name>/human-generator
$ docker run --network hello -itd --name lorem -h lorem <your name>/lorem-ipsum-world
$ docker run --network hello -itd --name math -p 9001:9001 -h math <your name>/math-world
$ docker run --network hello -itd --name hello -p 3000:3000 -h hello <your name>/hello-microservice

5. The last thing is go to http://localhost:3000

Returns 404:

curl -X GET http://localhost:3000

Returns 200:

curl -X GET http://localhost:3000/lorem

Returns 200:

curl -X GET http://localhost:3000/sum?numbers[]=1&numbers[]=2

Returns 200:

curl -X GET http://localhost:3000/human

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.