Deploying Angular app using NGINX in open shift

Latest response

I am trying to deploy a simple angular application to our on premise open shift platform.

This is my Docker file -

# Stage 1: Compile and Build angular codebase

# Use official node image as the base image
FROM node:10.15.3 as build
# Set the working directory
WORKDIR /app
COPY . .
RUN npm install
# Generate the build of the application
RUN npm run build --prod

# Stage 2: Serve app with nginx server
FROM nginx:1.17

COPY nginx.conf /etc/nginx/nginx.conf

WORKDIR /code

COPY --from=build /app/dist .

EXPOSE 8080:8080
CMD ["nginx", "-g", "daemon off;"]

I am using nginx.conf because of open shift security features around NGINX

# nginx.conf
worker_processes auto;

pid /tmp/nginx.pid;

events {
 worker_connections 1024;
}

http {
 include /etc/nginx/mime.types; 
 client_body_temp_path /tmp/client_temp;
 proxy_temp_path       /tmp/proxy_temp_path;
 fastcgi_temp_path     /tmp/fastcgi_temp;
 uwsgi_temp_path       /tmp/uwsgi_temp;
 scgi_temp_path        /tmp/scgi_temp;

 server {
   listen 8080;
   server_name _;

   charset utf-8;
   sendfile on;

   index index.html;
   error_log  /tmp/error.log;
   access_log /tmp/access.log;

   location / {
     root /code;
     try_files $uri /index.html;
   }
 }
}

I followed this blog to create docker file and nginx.conf
https://cloud.redhat.com/blog/deploy-vuejs-applications-on-openshift

The container runs fine in my local machine. But after deploying to openshift using deployment config, the url is showing 503 error always and also no errors in pod.

Any help on this will be much appreciated.
Error Message

Responses