Skip to content

gtsopour/nodejs-microservice-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NodeJS Microservice with Docker

Creating the app

The app creates a server with Express that has a single endpoint /api/user/:username. When a GET request reaches that endpoint, we go and fetch the given usernames json feed from Instagram and send it back as an response.

yarn install
yarn start

Navigate to http://localhost:8080/api/user/instagram should show Instagram's public feed as JSON.

Creating a Dockerfile

The Dockerfile takes the node:latest base image, copy some files in, install dependencies, expose a port and run the start command. Create a file called Dockerfile to the root of your project and add the following set of commands to that file:

Now we can build the image with docker build:

docker build -t nodejs-microservice-docker .

and then run it with docker run

docker run -it -p 8080:8080 nodejs-microservice-docker

List all containers (only IDs)

docker ps -aq

Stop all running containers

docker stop $(docker ps -aq)

Remove all containers

docker rm $(docker ps -aq)

Remove all images

docker rmi $(docker images -q)

License

MIT

About

NodeJS Microservice with Docker

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published