'Containerized application not accessible from browser

I am using Azure Kubernetes cluster and using below as dockerfile.The container is deployed successfully in a Pod.

FROM  node:12 as build-stage
WORKDIR /app
COPY package.json /app/
COPY package-lock.json /app/
RUN npm install
COPY ./ /app/
ARG URI
ENV REACT_APP_URI=$URI
RUN npm run build
EXPOSE 80
CMD exec /bin/bash -c "trap : TERM INT; sleep infinity & wait"

deployment yml file:

kind: Deployment
apiVersion: apps/v1
metadata:
  name: m-app
spec:
  replicas: 1
  selector:
    matchLabels:
      app: m-app
  template:
    metadata:
      labels:
        app: m-app
    spec:
      containers:
        - name: metadata-app
          image: >-
            <url>
          imagePullPolicy: Always
          env:
            - name: SECRET_USERNAME
              valueFrom:
                secretKeyRef:
                  name: dockersecret
                  key: username
            - name: SECRET_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: dockersecret
                  key: password
          ports:
            - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: m-app
  annotations:
    service.beta.kubernetes.io/azure-load-balancer-internal: "true"
spec:
  type: LoadBalancer
  selector:
    app: m-app
  ports:
    - name: http
      port: 80
      targetPort: 80
      protocol: TCP

I would use the above yml file for the deployment and I want to access the app via pvt IP Address . By running the above yml I would get the service m-app with an External private IP but it is not accessible.

Then I tried with NodePort and for the same I replace above LoadBalancer snippet with below:

kind: Service
apiVersion: v1
metadata:
  name: m-app
spec:
  type: NodePort
  ports:
    - port: 80
      targetPort: 80
      protocol: TCP
      nodePort: 31000
  selector:
    app: m-app

Again I can not access the app from my browser with :

Could someone please assist. I suspected an issue with the Dockerfile as well and used different Dockerfile but no luck.(Please ignore yml indentations if any)



Solution 1:[1]

Finally the issue got fixed . I added below snippet in the Dockerfile:

FROM httpd:alpine
WORKDIR /var/www/html
COPY ./httpd.conf /usr/local/apache2/conf/httpd.conf
COPY --from=build-stage /app/build/ .

along with:

FROM  node:12 as build-stage
WORKDIR /app
COPY package.json /app/
COPY package-lock.json /app/
RUN npm install
COPY ./ /app/
ARG URI
ENV REACT_APP_URI=$URI
RUN npm run build

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 UnicsSol