DEV Community

Cover image for #024 Docker with microservices
Omar
Omar

Posted on

#024 Docker with microservices

Introduction

this is part 24 from the journey it's a long journey(360 day) so go please check previous parts , and if you need to walk in the journey with me please make sure to follow because I may post more than once in 1 Day but surely I will post daily at least one 😍.

And I will cover lot of tools as we move on.


What is microservices

basically microservices is dividing our big application to small apps , each app can have his own front-end and backend but they can communicate with each other.


Architecture

architecture

This image explain how this project work .

.A front-end web app in Python or ASP.NET Core which lets you vote between two options
.A Redis or NATS queue which collects new votes
.A .NET Core, Java or .NET Core 2.1 worker which consumes votes and stores them in…
.A Postgres or TiDB database backed by a Docker volume
.A Node.js or ASP.NET Core SignalR webapp which shows the results of the voting in real time


Example

we are going to use docker official example go to this link and copy link to clone it locally
link
go the the terminal and type
clone

git clone https://github.com/dockersamples/example-voting-app.git
cd example-voting-app
Enter fullscreen mode Exit fullscreen mode

now the project is ready to build , we can see many docker-compose files run what ever is compatible with your machine.
I am going to use docker-compose-javaworker.yml
javaworker will use the java version not dotnet

up-java

docker-compose -f docker-compose-javaworker.yml up
Enter fullscreen mode Exit fullscreen mode

after finish building it's time to take a look at it
head in your browser to 127.0.0.1:5000 and in another window to 127.0.0.1:5001

browser

have fun with it try to vote and see change live !


docker-compose

compose

if you see they are using different services each use it's own front-end and back-end , and they are connected together using docker network you can see that vote and result connected to both networks back and front , but redis and worker and postgres are only to back-end.

that's a real example of power of docker how it's connected together to make a complete microservice app.

Also There is a deployment stack , it will be later later in the end when we cover all the tools , I will try to make an app contain all what we learn together :)

Top comments (0)