Has*_*him 6 node.js docker file-watcher dockerfile github-actions
需要在 docker 镜像中增加观察者,因为它在 expo 发布时失败并出现错误
[11:39:08] Error: ENOSPC: System limit for number of file watchers reached, watch '/__w/mevris-client-app-products/mevris-client-app-products/node_modules/update-notifier/node_modules/camelcase'
[11:39:08] at FSWatcher.start (internal/fs/watchers.js:165:26)
[11:39:08] at Object.watch (fs.js:1258:11)
[11:39:08] at NodeWatcher.watchdir (/__w/mevris-client-app-products/mevris-client-app-products/node_modules/metro/node_modules/sane/src/node_watcher.js:159:22)
[11:39:08] at Walker.<anonymous> (/__w/mevris-client-app-products/mevris-client-app-products/node_modules/metro/node_modules/sane/src/common.js:109:31)
[11:39:08] at Walker.emit (events.js:198:13)
[11:39:08] at /__w/mevris-client-app-products/mevris-client-app-products/node_modules/walker/lib/walker.js:69:16
[11:39:08] at go$readdir$cb (/__w/mevris-client-app-products/mevris-client-app-products/node_modules/@react-native-community/cli/node_modules/graceful-fs/graceful-fs.js:187:14)
[11:39:08] at FSReqWrap.args [as oncomplete] (fs.js:140:20)
Run Code Online (Sandbox Code Playgroud)
在 Dockerfile 中添加了以下几行
RUN echo "fs.inotify.max_user_instances=524288" >> /etc/sysctl.conf && sysctl -p
Run Code Online (Sandbox Code Playgroud)
构建时导致此错误
sysctl: setting key "fs.inotify.max_user_watches": Read-only file system
我需要在 Github Actions 中使用那个 docker 镜像
文件
FROM node:10
RUN echo "fs.inotify.max_user_instances=524288" >> /etc/sysctl.conf
RUN echo "fs.inotify.max_user_watches=524288" >> /etc/sysctl.conf
RUN echo "fs.inotify.max_queued_events=524288" >> /etc/sysctl.conf
RUN apt-get -qq update && apt-get -qq -y install bzip2
RUN yarn global add @bluebase/cli && bluebase plugins:add @bluebase/cli-expo && bluebase plugins:add @bluebase/cli-web
RUN bluebase plugins
RUN npm i -g expo-cli
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["sh", "/entrypoint.sh"]
Run Code Online (Sandbox Code Playgroud)
我在 Mac OSX(不是 docker-for-mac)上运行 Docker 时遇到了同样的问题。
基于 sysclt 设置与内核主机共享的前提,我修复了对 docker-machine (boot2docker) 执行 ssh 并更改那里的设置的问题。
$ docher-machine ssh
$ echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf
$ sudo sysctl -p
Run Code Online (Sandbox Code Playgroud)
您需要增加主机上的 fs.inotify.max_user_watches 参数。例如,您可以在 /etc/sysctl.d 中创建配置文件。示例 /etc/sysctl.d/crashplan.conf 内容如下:
fs.inotify.max_user_watches = 1048576
Run Code Online (Sandbox Code Playgroud)
您不能在构建时进行更改,因为它不会影响并且在构建期间也不允许您进行更改。
解决方法是避免出现此错误,在运行时在入口点中设置它。
FROM node:10.16
# set inotify and start the node application, replace yar with your command
RUN echo "#!/bin/sh \n\
echo "fs.inotify.max_user_watches before update" \n\
cat /etc/sysctl.conf\n\
echo "______________________________________________updating inotify ____________________________________" \n\
echo fs.inotify.max_user_watches=524288 | tee -a /etc/sysctl.conf && sysctl -p \n\
echo "updated value is" \n\
cat /etc/sysctl.conf | grep fs.inotify \n\
exec yarn start:dev \
" >> /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
# EXPOSE TARGET PORT
EXPOSE 3001
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6639 次 |
| 最近记录: |