简体   繁体   English

如何使用Docker和Angular重新加载实时更改?

[英]How can I do real-time changes reloading using Docker and Angular?

How can I do real-time changes reloading using Docker and Angular 4? 如何使用Docker和Angular 4重新加载实时更改? At this moment I have to rebuild my container to reload changes. 此时我必须重建我的容器以重新加载更改。 I know that it is possible however none of the methods found on the internet have worked for me. 我知道这是可能的,但互联网上找到的方法都没有对我有用。 I will be grateful for help. 我将不胜感激。

docker-compose.yml: 泊坞窗,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 from frontend: 来自前端的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"]

In your current configuration you only copy your app files to the container on creation, thus only once. 在当前配置中,您只能在创建时将应用程序文件复制到容器中,因此只能复制一次。 ( COPY . /usr/src/app ) COPY . /usr/src/app

I would recommend creating a volume link to your local directory and using a file change watcher like nodemon , so it can track any changes made and restart your app upon it. 我建议创建一个指向本地目录的卷链接 ,并使用像nodemon这样的文件更改观察 ,这样它就可以跟踪所做的任何更改并重新启动应用程序。 This is assuming you don't need any buildscripts like webpack/gulp/grunt to run. 这假设您不需要运行任何类似webpack / gulp / grunt的构建文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何检测输入值何时在 JavaScript 中实时变化? - How do I detect when input value changes real-time in JavaScript? JavaScript中如何创建实时变化 - How to create real-time changes in JavaScript 如何实时更新滑块的值? - How do I get the value of a slider to update in real-time? 如何使用 Node.js 和 Firebase 制作实时列表 - How can I make real-time list using Node.js and Firebase 如何使用 firebase / vue.js 实时删除 function - How can I make delete function real-time using firebase / vue.js Angular 2网站反映了不同计算机上的实时变化 - Angular 2 website reflects real-time changes on different computers 浏览器如何以及何时实现对文档DOM的实时更改? - How and when do browsers implement real-time changes to a document's DOM? 如何使用网络套接字从 GDAX 中获取比特币价格,以便实时更改价值? - How to scrape Bitcoin prices from GDAX using web sockets so that the value changes in real-time? 如何听firebase实时变化成Reactjs? - How to listen firebase real-time changes into Reactjs? 如何使用履行部分中的Node.js接收实时数据库中的最新数据? - How do i receive the most recent data in Real-Time Database using the Node.js in the fulfillment section?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM