简体   繁体   English

Docker-compose-Ruby-罗盘-inotify

[英]Docker-compose - Ruby - Compass - inotify

I'm trying to make a Docker container able to watch my projects and compile what should be compiled. 我正在尝试使Docker容器能够监视我的项目并编译应编译的内容。 With Sass, I have some issues related to inotify. 使用Sass,我遇到了一些与inotify相关的问题。

When I try to launch : 当我尝试启动时:

compass watch --sass-dir /var/www/project/styles/sass/ --css-dir /var/www/project/styles/ -c /var/www/project/styles/config.rb

I've got this error: 我有这个错误:

root@88843683f769:/# compass watch --sass-dir /var/www/lbo_legacy/styles/sass --css-dir /var/www/lbo_legacy/styles/ -c /var/www/lbo_legacy/styles/config.rb --trace
>>> Compass is watching for changes. Press Ctrl-C to Stop.
Errno::EMFILE on line ["58"] of /var/lib/gems/2.3.0/gems/rb-inotify-0.9.10/lib/rb-inotify/notifier.rb: Too many open files - Failed to initialize inotify: the user limit on the total number of inotify instances has been reached.
  /var/lib/gems/2.3.0/gems/sass-3.4.22/vendor/listen/lib/listen/adapters/linux.rb:66:in `new'
  /var/lib/gems/2.3.0/gems/sass-3.4.22/vendor/listen/lib/listen/adapters/linux.rb:66:in `initialize_worker'
  /var/lib/gems/2.3.0/gems/sass-3.4.22/vendor/listen/lib/listen/adapter.rb:87:in `initialize'
  /var/lib/gems/2.3.0/gems/sass-3.4.22/vendor/listen/lib/listen/adapters/linux.rb:31:in `initialize'
  /var/lib/gems/2.3.0/gems/sass-3.4.22/vendor/listen/lib/listen/adapter.rb:228:in `new'
  /var/lib/gems/2.3.0/gems/sass-3.4.22/vendor/listen/lib/listen/adapter.rb:228:in `works?'
  /var/lib/gems/2.3.0/gems/sass-3.4.22/vendor/listen/lib/listen/adapter.rb:190:in `block in usable_and_works?'
  /var/lib/gems/2.3.0/gems/sass-3.4.22/vendor/listen/lib/listen/adapter.rb:190:in `each'
  /var/lib/gems/2.3.0/gems/sass-3.4.22/vendor/listen/lib/listen/adapter.rb:190:in `all?'
  /var/lib/gems/2.3.0/gems/sass-3.4.22/vendor/listen/lib/listen/adapter.rb:190:in `usable_and_works?'
  /var/lib/gems/2.3.0/gems/sass-3.4.22/vendor/listen/lib/listen/adapter.rb:57:in `block in select_and_initialize'
  /var/lib/gems/2.3.0/gems/sass-3.4.22/vendor/listen/lib/listen/adapter.rb:55:in `each'
  /var/lib/gems/2.3.0/gems/sass-3.4.22/vendor/listen/lib/listen/adapter.rb:55:in `select_and_initialize'
  /var/lib/gems/2.3.0/gems/sass-3.4.22/vendor/listen/lib/listen/listener.rb:291:in `initialize_adapter'
  /var/lib/gems/2.3.0/gems/sass-3.4.22/vendor/listen/lib/listen/listener.rb:283:in `setup'
  /var/lib/gems/2.3.0/gems/sass-3.4.22/vendor/listen/lib/listen/listener.rb:65:in `start!'
  /var/lib/gems/2.3.0/gems/sass-3.4.22/lib/sass/plugin/compiler.rb:408:in `listen_to'
  /var/lib/gems/2.3.0/gems/sass-3.4.22/lib/sass/plugin/compiler.rb:341:in `watch'
  /var/lib/gems/2.3.0/gems/compass-1.0.3/lib/compass/sass_compiler.rb:46:in `watch!'
  /var/lib/gems/2.3.0/gems/compass-1.0.3/lib/compass/commands/watch_project.rb:41:in `perform'
  /var/lib/gems/2.3.0/gems/compass-1.0.3/lib/compass/commands/base.rb:18:in `execute'
  /var/lib/gems/2.3.0/gems/compass-1.0.3/lib/compass/commands/project_base.rb:19:in `execute'
  /var/lib/gems/2.3.0/gems/compass-1.0.3/lib/compass/exec/sub_command_ui.rb:43:in `perform!'
  /var/lib/gems/2.3.0/gems/compass-1.0.3/lib/compass/exec/sub_command_ui.rb:15:in `run!'
  /var/lib/gems/2.3.0/gems/compass-1.0.3/bin/compass:30:in `block in <top (required)>'
  /var/lib/gems/2.3.0/gems/compass-1.0.3/bin/compass:44:in `<top (required)>'
  /usr/local/bin/compass:23:in `load'
  /usr/local/bin/compass:23:in `<main>'

I've tried too increase rb-inotify user limit, but still the same error. 我也尝试过增加rb-inotify用户限制,但仍然是相同的错误。

My Dockerfile : 我的Dockerfile:

FROM ubuntu:latest

ENV DEBIAN_FRONTEND noninteractive

RUN echo fs.inotify.max_user_watches=500000 | tee -a /etc/sysctl.conf
RUN echo fs.inotify.max_queued_events=500000 | tee -a /etc/sysctl.conf
RUN apt-get --quiet update

RUN apt-get install --yes --no-install-recommends gnupg2 vim wget git curl ca-certificates

# Node.js (and NPM).
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash - \
    && apt-get install --yes nodejs build-essential

#Ruby
RUN apt-get install -y ruby ruby-dev rubygems

# Rake.
RUN gem install --no-rdoc --no-ri rake

#Sass
RUN gem install --no-rdoc --no-ri sass -v 3.4.22

# Compass.
RUN gem install --no-rdoc --no-ri compass

# Bower, Grunt CLI, Gulp.
RUN npm install --global bower grunt-cli gulp

# Clean up.
RUN apt-get autoremove --yes \
    && apt-get clean

If I run "sysctl -p": 如果我运行“ sysctl -p”:

root@88843683f769:/# sysctl -p
fs.inotify.max_user_watches = 500000
fs.inotify.max_queued_events = 500000

If needed, my config.rc (but same behaviour with or without the -c parameter ...) 如果需要,请使用我的config.rc(但是无论是否带有-c参数,其行为相同...)

require 'compass/import-once/activate'
# Require any additional compass plugins here.
add_import_path "../assets/zurb_mail/node_modules/foundation-emails/scss"
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "."
sass_dir = "sass"
images_dir = "images"
javascripts_dir = "javascripts"

# You can select your preferred output style here (can be overridden via the command line):
# output_style = :expanded or :nested or :compact or :compressed
output_style= :compressed

# To enable relative paths to assets via compass helper functions. Uncomment:
# relative_assets = true

# To disable debugging comments that display the original location of your selectors. Uncomment:
# line_comments = false


# If you prefer the indented syntax, you might want to regenerate this
# project again passing --syntax sass, or you can uncomment this:
# preferred_syntax = :sass
# and then run:
# sass-convert -R --from scss --to sass sass scss && rm -rf sass && mv scss sass

It works fine on my Ubuntu host tho ... 它可以在我的Ubuntu主机上正常工作...

Any ideas guys ? 有什么想法吗?

So, I didn't really solved the problem, but I've found a workarround. 因此,我并没有真正解决问题,但是我找到了一个解决方法。 Adding -poll tag on the compass watch command do the trick. 在指南针监视命令上添加-poll标记可以达到目的。 It use a timer instead of the system file events. 它使用计时器而不是系统文件事件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM