Kal*_*sev 10 docker docker-compose angular-cli angular
我是'dockersizing'(我希望这是正确的术语)现有的Angular 2应用程序,运行于angular-cli(1.0.0-beta.31).
ng serve每当我更新工作目录中的文件时,我都在努力找到一种方法来捕获 - 因此 - 刷新我的应用程序(像往常一样).否则,我docker-compose up --build每次都需要更改文件...
编辑:我正在探索的想法是添加一个卷.
这是我的Dockerfile:
# Dockerizing Angular 2 Client App
# @link: https://scotch.io/tutorials/create-a-mean-app-with-angular-2-and-docker-compose
# Create image based on the official Node 7 image from dockerhub
FROM node:7
# 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
# **EDIT**: comment out this, so I can set-up a volume
# COPY . /usr/src/app
# Expose the port the app runs in
EXPOSE 4200
# Serve the app
CMD ["npm", "start"]
Run Code Online (Sandbox Code Playgroud)
这是我的docker-compose.yml:
# specify docker-compose version
version: '2'
# Define the services/containers to be run
services:
angular2app: # name of the service
build: ./ # specify the directory of the Dockerfile
ports:
- "4200:4200" # specify port forewarding
# **EDIT**: Setting-up the volume here
volumes:
- .:/usr/src/app
Run Code Online (Sandbox Code Playgroud)
编辑:没有卷配置 - 应用程序构建并成功运行.设置卷后,错误输出:
Building angular2app
Step 1/7 : FROM node:7
---> b3a95b94bd6c
Step 2/7 : RUN mkdir -p /usr/src/app
---> Using cache
---> 2afb01ffe055
Step 3/7 : WORKDIR /usr/src/app
---> Using cache
---> 44d08fdb4a19
Step 4/7 : COPY package.json /usr/src/app
---> Using cache
---> 87bb4f71c13c
Step 5/7 : RUN npm install
---> Using cache
---> ba88a0e1e480
Step 6/7 : EXPOSE 4200
---> Using cache
---> 4fddacae8486
Step 7/7 : CMD npm start
---> Using cache
---> c5ac29bf85fc
Successfully built c5ac29bf85fc
Creating minterface_angular2app_1
ERROR: for angular2app Cannot start service angular2app: Mounts denied: closed
ERROR: Encountered errors while bringing up the project.
Run Code Online (Sandbox Code Playgroud)
如何配置ng serve以捕获当前工作目录中的更改并重新构建我的Angular 2应用程序?
PS:我使用Docker -compose版本1.11.1(版本7c5d5e4),通过Docker for Mac在Mac(Sierra 10.12.3)上运行.
小智 2
您可以使用此 npm 包:https://www.npmjs.com/package/supervisor
只需使用该主管进程运行该进程,并指定它应该监视哪些文件夹的-w更改并重新启动。
希望有帮助!
| 归档时间: |
|
| 查看次数: |
3241 次 |
| 最近记录: |