我如何使用Docker和Angular做实时更改重装?

如何使用Docker和Angular 4来实时更改重新加载? 在这一刻,我不得不重build我的容器重新加载更改。 我知道这是可能的,但是没有任何在互联网上find的方法为我工作。 我会感激的帮助。

泊坞窗,compose.yml:

version: '3' services: db: image: postgres django: build: . command: python3 manage.py runserver 0.0.0.0:8000 volumes: - .:/code ports: - "8000:8000" depends_on: - db angular: build: frontend ports: - "4200:4200" depends_on: - django 

来自前端的Dockerfile:

 # Create image based on the official Node 6 image from dockerhub FROM node:6 # Create a directory where our app will be placed RUN mkdir -p /usr/src/app # Change directory so that our commands run inside this new directory WORKDIR /usr/src/app # Copy dependency definitions COPY package.json /usr/src/app # Install dependecies RUN npm install # Get all the code needed to run the app COPY . /usr/src/app # Expose the port the app runs in EXPOSE 4200 # Serve the app CMD ["npm", "start"] 

在您当前的configuration中,您只能在创build时将应用程序文件复制到容器,因此只能复制一次。 ( COPY . /usr/src/app

我build议创build一个到本地目录的卷链接 ,并使用像nodemon这样的文件更改监视器 ,以便它可以跟踪所做的任何更改并重新启动您的应用程序。 假设你不需要像webpack / gulp / grunt这样的任何buildscript来运行。