I am using nestjs to create microservice. Following is my .env for gateway
PORT=3002
MSA_USER_HOST=127.0.0.1
MSA_USER_PORT=3001
gateway is running on localhost:3002 and user microservice is running on port 3001.following is my Dockerfile for gateway.
FROM node:14.16.0
WORKDIR /usr/src/app
COPY package*.json ./
COPY . .
RUN npm install rimraf && npm install && npm audit fix && npm run build
EXPOSE 3002
CMD ["node", "dist/main"]
I create/run docker image using following command
docker build -t gateway:V1.0.0 .
docker run --rm -d --network local --network-alias internal -p 3002:3002 gateway:V1.0.0
I am able to access my gateway using localhost:3002. Problem starts when gateway try to connect with user api container. following is my Dockerfile for user api.
FROM node:14.16.0
WORKDIR /usr/src/app
COPY package*.json ./
COPY . .
RUN npm install rimraf && npm install && npm audit fix && npm run build
EXPOSE 3001
CMD ["node", "dist/main"]
I create/run user api container using following commands.
docker build -t userapi:V1.0.0 .
docker run --rm -d --network local --network-alias internal -p 3001:3001 userapi:V1.0.0
when I check log service is running but application running on localhost:3002 is not able to communicate with userapi. Does any have any idea where I am making mistake.
let me know if you want me to share something else to help me.
thanks