[英]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.