Had*_*OMA 5 docker dockerfile mounted-volumes angular-cli angular
遵循以下步骤:
定义 Dockerfile:
FROM node:alpine
RUN yarn global add @angular/cli
RUN yarn global add node-sass
RUN mkdir /volumes
WORKDIR /volumes
EXPOSE 4200
ENTRYPOINT ["ng"]
Run Code Online (Sandbox Code Playgroud)从这个 Dockerfile 构建一个镜像:
docker build -t my_angular_image .
Run Code Online (Sandbox Code Playgroud)使用图像创建一个新的 angular 应用程序:
// Create the new app
docker run --rm --mount type=bind,src=$PWD,dst=/volumes my_angular_image new my-app --directory app --style scss
// Change ownership of the generated app
sudo chown -R $USER:$USER .
Run Code Online (Sandbox Code Playgroud)根据镜像,运行一个容器绑定挂载应用程序卷:
docker run -p 4200:4200 --mount type=bind,src=$PWD/app,dst=/volumes my_angular_image serve --host 0.0.0.0
Run Code Online (Sandbox Code Playgroud)结果:
第一次编译按预期工作,容器为应用程序提供服务。但是,当更改必须ng serve在容器中监视的文件的值(来自主机)时,不会触发新的角度构建(因此,不会更新服务的应用程序)。
问题:
有人知道为什么在主机上更改绑定安装卷的值不会触发ng serve容器中的角度更新(就像不使用 Docker 时那样)?
环境:
为了使示例正常工作,请用以下命令替换步骤 3:
// Create the new app
docker run --rm --mount type=bind,src=$PWD,dst=/volumes my_angular_image new my-app --directory app --style scss
// Change ownership of the generated app
sudo chown -R $USER:$USER .
// Configure angular-cli polling:
sed -i 's/\"styleExt\": \"scss\",/"styleExt": "scss", "poll": 1000,/g' $PWD/app/.angular-cli.json
Run Code Online (Sandbox Code Playgroud)
学分:
| 归档时间: |
|
| 查看次数: |
1734 次 |
| 最近记录: |