问题:
运行 skaffold 并更新监视的文件时,我看到文件同步更新发生并且 nodemon 重新启动服务器,但刷新页面并没有显示更改。直到我完全停止 skaffold 并重新启动后,我才看到了变化。
Syncing 1 files for test/dev-client:e9c0a112af09abedcb441j4asdfasfd1cf80f2a9bc80342fd4123f01f32e234cfc18
Watching for changes every 1s...
[client-deployment-656asdf881-m643v client] [nodemon] restarting due to changes...
[client-deployment-656asdf881-m643v client] [nodemon] starting `node bin/server.js`
设置:
我有一个简单的微服务应用程序。它有一个服务器端(flask/python)和一个客户端(react),可以快速处理开发服务器。我有 nodemon 与旧的手表标志为真(对于 Chokidar 轮询)。在开发中,我通过 Docker for Mac 使用 Kubernetes。
代码:
我很高兴发布我的代码以提供帮助。让我知道哪些是最需要的。
这里有一些开场白:
Skaffold.yaml:
apiVersion: skaffold/v1beta7
kind: Config
build:
local:
push: false
artifacts:
- image: test/dev-client
docker:
dockerfile: Dockerfile.dev
context: ./client
sync:
'**/*.css': .
'**/*.scss': .
'**/*.js': .
- image: test/dev-server
docker:
dockerfile: Dockerfile.dev
context: ./server
sync:
'**/*.py': .
deploy:
kubectl:
manifests:
- k8s-test/client-ip-service.yaml
- k8s-test/client-deployment.yaml
- k8s-test/ingress-service.yaml
- k8s-test/server-cluster-ip-service.yaml
- k8s-test/server-deployment.yaml
Package.json 的相关部分:
"start": "nodemon -L bin/server.js",
Dockerfile.dev(客户端):
# base image
FROM node:10.8.0-alpine
# setting the working directory
# may have to run this depending on environment
# RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
# add '/usr/src/app/node_modules/.bin' to $PATH
ENV PATH /usr/src/app/node_modules/.bin:$PATH
# install and cache app depencies
COPY package.json /usr/src/app/package.json
RUN npm install
# copy over everything else
COPY . .
# start the app.
CMD ["npm", "run", "start"]