How to Containerize an AngularJS Application Featuring Nginx Using Docker Containers




Step 1
Dockerfile
FROM node:14.20.0-alpine as build-step
RUN mkdir -p /app
WORKDIR /app
COPY package.json /app
RUN npm install
COPY . /app
RUN npm run build --prod
Step 2
FROM nginx:1.20.1
COPY --from=build-step /app/dist/angular-apps /usr/share/nginx/html
EXPOSE 4200:80

docker-compose.yml
version: "3.7"
services:
    angular-service:
       container_name: ng-docker-example
       build: .
       ports:
           - "4200:80"
   
The build command should look as shown below
docker-compose build angular-service
docker-compose up
http://localhost:4200
Source:











Share on Google Plus

About Ram Pukar

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment

0 comments:

Post a Comment