Localhost displays only NGINX welcome page after running my app Angular application container

Discussão em 'Angular' iniciado por Elyes Besbes, Novembro 20, 2024.

  1. Elyes Besbes

    Elyes Besbes Guest

    I want to dockerize my Angular 17 application. This is my dockerfile

    # Stage 1: Build the Angular application
    FROM node:18.14 AS builder
    WORKDIR /app
    COPY package.json package-lock.json ./
    RUN npm install
    COPY . .
    RUN npm run build -- --configuration production

    # Stage 2: Serve the Angular application using Nginx
    FROM nginx:latest
    COPY --from=builder /app/dist/dwir-app /usr/share/nginx/html
    EXPOSE 80
    CMD ["nginx", "-g", "daemon off;"]


    I built my dockerfile and runned a container from the image of my application on port 4201:

    docker run -d --name dwira_website_version2 -p 4201:80 dwiraversion1


    I verified using docker ps that my container is running and tried to access my application using http://localhost:80 and I only get the welcome page of nginx. I tried also http://localhost:80/index.html and had the same result

    I tired to see my app on localhost and didn't work because I only see the welcome page of NGINX.

    this is my nginx.conf file:

    server {
    listen 80;

    location / {
    root /usr/share/nginx/html;
    index index.html ;
    try_files $uri $uri/ /index.html =404;
    }

    }

    Continue reading...

Compartilhe esta Página