Skip to content

id1945/angular-docker

Repository files navigation

[1] Dockerfile local

[1.1] Dockerfile

FROM node:14-stretch-slim as build
WORKDIR /app
COPY ./ /app
RUN npm install && npm run build

FROM nginx:latest
COPY --from=build /app/dist/angular-docker /usr/share/nginx/html

[1.2] Virtual machine

Create image

docker build -t angular_build -f Dockerfile .

Run container

docker run -d --name angular_host -p 8080:80 angular_build
docker ps -la
docker stop angular_host
docker start angular_host
docker rm angular_host
Test: http://localhost:8080/

[2] Dockerfile on docker-hub

[2.1] Push Dockerfile to docker-hub

docker login
docker tag angular-demo:latest id1945/angular-demo
docker push id1945/angular-demo
Check: https://hub.docker.com/r/id1945/angular-demo

[2.2] Run container by docker-compose

docker-compose.yml

version: "3.3"
services:
  web-angular:
    image: id1945/angular-demo:latest
    ports:
      - "8080:80"
docker-compose up -d
Test: http://localhost:8080/

[3] Run docker-compose with ssh file

deploy.ssh

docker-compose stop
docker-compose rm -f
docker-compose pull
docker-compose up -d

Run deploy.ssh

chmod +x deploy.sh
./deploy.sh
Test: http://localhost:8080/

What?

-d (Run in background) Refer: https://giai-ma.blogspot.com/2020/08/tim-hieu-docker-images-containers.html

Author: DaiDH Tel: 0845882882

About

docker-basic, angular, dockerfile, docker-compose, docker-hub

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published