In this video, I'll show how to create and run Angular app using Docker, without installing Node in the Host machine.
- Create folder
$ mkdir ng-docker && cd ng-docker
- Create
Dockerfile
file
FROM node:12-alpine
LABEL AUTHOR="Arunkumar Dharuman"
WORKDIR /code
RUN npm install -g @angular/cli
- Create
docker-compose.yaml
file
version: "3.8"
services:
app:
build: .
restart: always
volumes:
- "/code/node_modules"
- ./:/code
ports:
- 4200:4200
commands:
ng serve --host 0.0.0.0
- Create Angular project without installing packages
$ docker-compose run app ng new ng-docker --directory . --skipInstall
- Update
Dockerfile
file and append following lines
RUN npm install -g @angular/cli
COPY package*.json ./
RUN npm install
- Run
docker-compose
$ docker-compose up --build
- Further, from next run
$ docker-compose up
Hope this helps!