更改角度代码不会触发重新加载docker内部的应用程序

时间:2018-11-11 22:09:24

标签: angular docker visual-studio-code docker-compose

我发现here是一个docker-compose项目:

version: '3.1'

services:

  nginx:
    container_name: nginx
    image: nginx
    build:
      context: .
      dockerfile: .docker/nginx.dockerfile
    volumes:
      - ./dist:/usr/share/nginx/html
    ports:
      - "80:80"
      - "443:443"

    networks:
      - app-network

  node:
    container_name: nodeapp
    image: nodeapp
    build:
      context: ./microservices/node
      dockerfile: .docker/node.development.dockerfile
    volumes:
      - ./microservices/node:/var/www/angularnoderestfulservice
    environment:
      - NODE_ENV=development
    ports:
      - "3000:3000"
    depends_on: 
      - mongodb
    networks:
      - app-network

  #No authentication is provided here - JUST A DEMO! That would absolutely
  #be needed for a "real" application
  mongodb:
    container_name: mongodb
    image: mongo
    networks:
      - app-network

  aspnet:
    container_name: 'aspnetcoreapp'
    image: 'aspnetcoreapp'
    build:
      context: ./microservices/aspnet_core
      dockerfile: .docker/aspnetcore.development.dockerfile
    volumes:
      - ./microservices/aspnet_core:/var/www/aspnetcoreapp
    ports:
     - "5000:5000"
    depends_on:
     - "postgres"
    networks:
      - app-network

  postgres:
    container_name: 'postgres'
    image: postgres
    environment:
      POSTGRES_PASSWORD: password
    networks:
      - app-network

  cadvisor:
    container_name: cadvisor
    image: google/cadvisor
    volumes:
      - /:/rootfs:ro
      - /var/run:/var/run:rw
      - /sys:/sys:ro
      - /var/lib/docker/:/var/lib/docker:ro
    ports:
      - "8080:8080"
    networks:
      - app-network

networks:
  app-network:
    driver: bridge

不幸的是,当我将src/index.html的更改保存在vs代码中时,并没有触发将其重新加载到docker内部。

我想念什么?

先谢谢您

米哈尔

1 个答案:

答案 0 :(得分:0)

使用nginx进行投放时,它会在/ dist文件夹中提供Angular应用程序的内置版本(通过ng build)。您正在使用ng serve寻找angular的实时开发功能。

看看这个仓库https://github.com/willcrisis/ng-docker/blob/master/README.md