Driss Outraah
Driss Outraah

Reputation: 1

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

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

Dockerfile : "FROM node:18-alpine As builder

WORKDIR /usr/src/app

COPY package.json package-lock.json ./

RUN npm install

COPY . .

RUN npm run build

FROM nginx:1.15.8-alpine

RUN rm -rf /usr/share/nginx/html/*
COPY --from=builder /usr/src/app/dist/application_immobilier/browser /usr/share/nginx/html/ CMD ["nginx", "-g", "daemon off;"]

EXPOSE 4200 "

do you have an idea please ?

run container with my app

Upvotes: 0

Views: 78

Answers (1)

0xn0b174
0xn0b174

Reputation: 1022

try this:

# Stage 1: Build the Angular app
FROM node:18-alpine AS builder

WORKDIR /usr/src/app

COPY package.json package-lock.json ./
RUN npm install

COPY . .

RUN npm run build   # Build the Angular app in production mode

# Stage 2: Serve the Angular app with NGINX
FROM nginx:1.15.8-alpine

# Remove the default NGINX welcome page
RUN rm -rf /usr/share/nginx/html/*

# Copy Angular build files to NGINX html directory
COPY --from=builder /usr/src/app/dist/my-angular-app/browser /usr/share/nginx/html

# Set correct permissions for NGINX to serve files
RUN chmod -R 755 /usr/share/nginx/html

EXPOSE 80

# Start NGINX server
CMD ["nginx", "-g", "daemon off;"]


i tested : enter image description here

Upvotes: 0

Related Questions