simple-microservice-example
simple-microservice-example copied to clipboard
A very simple microservice example with NodeJS, Python and Docker
Simple Microservice Example
A very simple microservice example with NodeJS, Python and Docker
Run the API gateway
-
Install
dockeranddocker-composeaccording to your operating system -
Clone the repository and navigate to it
-
Run
docker-compose upto start the services -
Try
GET http://YOUR_HOST:3000/api/statusto check whether application is running
Build the frontend
The application uses a frontend written with plain html with jQuery and to style with Bulma.
This is built with webpack. This default application is built assuming you are using the localhost.
To build this to fit your own IP Address please follow the steps before you running the docker-compose up
-
Install NodeJs on your system
-
Go to FrontendApplication directory
-
Run
npm installor if you have yarnyarnto install packages -
Now you need to set the API Gateway for this frontend application. It can be any host you have.
- Let's say you are hosting this application on
http://example.comthen yourAPI_GATEWAYwould be this one. - If you are hosting in some machine with IP
123.324.345.1then yourAPI_GATEWAYwould be your IP.
- Let's say you are hosting this application on
-
To pass this setting to webpack build you need to set an Environment Variable
- Windows :
set API_GATEWAY=http://YOUR_HOST - Linux/Max :
API_GATEWAY=http://YOUR_HOST
- Remember no / at the end of the URL to get your web app work
- Windows :
-
Now you can do
npm run buildoryarn build -
Check
dist/folder for newly created index.html and the main.js -
Now run the
docker-compose upon the root folder of project and checkhttp://YOUR_HOST:8080to see web app
