An Interest In:
Web News this Week
- March 3, 2024
- March 2, 2024
- March 1, 2024
- February 29, 2024
- February 28, 2024
- February 27, 2024
- February 26, 2024
January 8, 2022 03:27 pm GMT
Original Link: https://dev.to/imabtiwari/dockerize-angular-app-l3i
Dockerize Angular App
Agenda
Dockerize an Angular app, built with the Angular CLI, using Docker, In this blog we will have a walkthrough of angular 7 and dockerize it over node image(base).
Here, we specifically focus on:
- Create an angular app using CLI and test it locally
- Create an image for dev environment with code Hot-reloading
Project Setup
Install the Angular CLI globally:
npm install -g @angular/[email protected]
Generate a new app aka angular-microservice using CLI:
ng new angular-microservice cd angular-microservice
(optional)To generate in present dir use:
ng new angular-microservice directory ./
Docker Setup
Add a Dockerfile to the project root:
# base imageFROM node:12.2.0# set working directoryWORKDIR /app# install and cache app dependenciesCOPY package.json /app/package.jsonRUN npm installRUN npm install -g @angular/[email protected]# add appCOPY . /app# start appCMD ng serve --host 0.0.0.0
Building Docker image
docker build -t angular-microservice:dev .
Run Docker Image
Run the container after the build is done:
docker run -d -v ${PWD}:/app -v /app/node_modules -p 4201:4200 --rm angular-microservice:dev
Use the -d flag to run the container in the background:
docker run -d -v ${PWD}:/app -v /app/node_modules -p 4201:4200 --name foo --rm angular-microservice:dev
Please react if you found this blog helpful and informational.
Original Link: https://dev.to/imabtiwari/dockerize-angular-app-l3i
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To