Docker and Sphinx

Hi,

I’m using the docker compose setup for my production environment. One ‘web’ service, one worker ‘service’, and additional memchached container and Sphinx is installed in the ‘web’ service container, which works fine for the search of the web service, but the job worker also wants to index the listing deltas and cannot access to sphinx which is in the web container. I Get the following error, any idea how I can fix this?

Permission denied @ rb_sysopen - /opt/app/db/sphinx/production/ts-listing_delta.tmp
/usr/local/lib/ruby/2.3.0/fileutils.rb:1158:in initialize' /usr/local/lib/ruby/2.3.0/fileutils.rb:1158:inopen’
/usr/local/lib/ruby/2.3.0/fileutils.rb:1158:in rescue in block in touch' /usr/local/lib/ruby/2.3.0/fileutils.rb:1154:inblock in touch’
/usr/local/lib/ruby/2.3.0/fileutils.rb:1152:in each' /usr/local/lib/ruby/2.3.0/fileutils.rb:1152:intouch’
/opt/app/vendor/bundle/ruby/2.3.0/gems/thinking-sphinx-3.3.0/lib/thinking_sphinx/guard/file.rb:9:in lock' /opt/app/vendor/bundle/ruby/2.3.0/gems/thinking-sphinx-3.3.0/lib/thinking_sphinx/guard/files.rb:13:ineach’
/opt/app/vendor/bundle/ruby/2.3.0/gems/thinking-sphinx-3.3.0/lib/thinking_sphinx/guard/files.rb:13:in call' /opt/app/vendor/bundle/ruby/2.3.0/gems/thinking-sphinx-3.3.0/lib/thinking_sphinx/guard/files.rb:3:incall’
/opt/app/vendor/bundle/ruby/2.3.0/gems/thinking-sphinx-3.3.0/lib/thinking_sphinx/controller.rb:7:in block in index' /opt/app/vendor/bundle/ruby/2.3.0/gems/thinking-sphinx-3.3.0/lib/thinking_sphinx/indexing_strategies/all_at_once.rb:5:incall’
/opt/app/vendor/bundle/ruby/2.3.0/gems/thinking-sphinx-3.3.0/lib/thinking_sphinx/controller.rb:6:in index' /opt/app/vendor/bundle/ruby/2.3.0/gems/thinking-sphinx-3.3.0/lib/thinking_sphinx/deltas/index_job.rb:7:inperform’
/opt/app/vendor/bundle/ruby/2.3.0/bundler/gems/ts-delayed-delta-0aef2195f3ac/lib/thinking_sphinx/deltas/delayed_delta/delta_job.rb:22:in perform' /opt/app/vendor/bundle/ruby/2.3.0/gems/delayed_job-4.1.3/lib/delayed/backend/base.rb:81:inblock in invoke_job’
/opt/app/config/initializers/delayed_job.rb:10:in block (2 levels) in <class:DelayedJobLoggerPlugin>' /opt/app/vendor/bundle/ruby/2.3.0/gems/delayed_job-4.1.3/lib/delayed/lifecycle.rb:79:inblock (2 levels) in add’
/opt/app/vendor/bundle/ruby/2.3.0/gems/airbrake-6.1.2/lib/airbrake/delayed_job.rb:11:in block (2 levels) in <class:Airbrake>' /opt/app/vendor/bundle/ruby/2.3.0/gems/delayed_job-4.1.3/lib/delayed/lifecycle.rb:79:inblock (2 levels) in add’
/opt/app/vendor/bundle/ruby/2.3.0/gems/delayed_job-4.1.3/lib/delayed/lifecycle.rb:61:in block in initialize' /opt/app/vendor/bundle/ruby/2.3.0/gems/delayed_job-4.1.3/lib/delayed/lifecycle.rb:79:inblock in add’
/opt/app/vendor/bundle/ruby/2.3.0/gems/delayed_job-4.1.3/lib/delayed/lifecycle.rb:79:in block in add' /opt/app/vendor/bundle/ruby/2.3.0/gems/delayed_job-4.1.3/lib/delayed/lifecycle.rb:66:inexecute’
/opt/app/vendor/bundle/ruby/2.3.0/gems/delayed_job-4.1.3/lib/delayed/lifecycle.rb:40:in run_callbacks' /opt/app/vendor/bundle/ruby/2.3.0/gems/delayed_job-4.1.3/lib/delayed/backend/base.rb:78:ininvoke_job’
/opt/app/vendor/bundle/ruby/2.3.0/gems/newrelic_rpm-4.2.0.334/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb:129:in block in invoke_job' /opt/app/vendor/bundle/ruby/2.3.0/gems/newrelic_rpm-4.2.0.334/lib/new_relic/agent/instrumentation/controller_instrumentation.rb:362:inperform_action_with_newrelic_trace’
/opt/app/vendor/bundle/ruby/2.3.0/gems/newrelic_rpm-4.2.0.334/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb:128:in invoke_job' /opt/app/vendor/bundle/ruby/2.3.0/gems/delayed_job-4.1.3/lib/delayed/worker.rb:230:inblock (2 levels) in run’
/usr/local/lib/ruby/2.3.0/timeout.rb:91:in block in timeout' /usr/local/lib/ruby/2.3.0/timeout.rb:101:intimeout’
/opt/app/vendor/bundle/ruby/2.3.0/gems/delayed_job-4.1.3/lib/delayed/worker.rb:230:in block in run' /usr/local/lib/ruby/2.3.0/benchmark.rb:308:inrealtime’
/opt/app/vendor/bundle/ruby/2.3.0/gems/delayed_job-4.1.3/lib/delayed/worker.rb:229:in run' /opt/app/vendor/bundle/ruby/2.3.0/gems/delayed_job-4.1.3/lib/delayed/worker.rb:312:inblock in reserve_and_run_one_job’
/opt/app/vendor/bundle/ruby/2.3.0/gems/delayed_job-4.1.3/lib/delayed/lifecycle.rb:61:in block in initialize' /opt/app/vendor/bundle/ruby/2.3.0/gems/delayed_job-4.1.3/lib/delayed/lifecycle.rb:66:inexecute’
/opt/app/vendor/bundle/ruby/2.3.0/gems/delayed_job-4.1.3/lib/delayed/lifecycle.rb:40:in run_callbacks' /opt/app/vendor/bundle/ruby/2.3.0/gems/delayed_job-4.1.3/lib/delayed/worker.rb:312:inreserve_and_run_one_job’
/opt/app/vendor/bundle/ruby/2.3.0/gems/delayed_job-4.1.3/lib/delayed/worker.rb:213:in block in work_off' /opt/app/vendor/bundle/ruby/2.3.0/gems/delayed_job-4.1.3/lib/delayed/worker.rb:212:intimes’
/opt/app/vendor/bundle/ruby/2.3.0/gems/delayed_job-4.1.3/lib/delayed/worker.rb:212:in work_off' /opt/app/vendor/bundle/ruby/2.3.0/gems/delayed_job-4.1.3/lib/delayed/worker.rb:175:inblock (4 levels) in start’
/usr/local/lib/ruby/2.3.0/benchmark.rb:308:in realtime' /opt/app/vendor/bundle/ruby/2.3.0/gems/delayed_job-4.1.3/lib/delayed/worker.rb:174:inblock (3 levels) in start’
/opt/app/vendor/bundle/ruby/2.3.0/gems/delayed_job-4.1.3/lib/delayed/lifecycle.rb:61:in block in initialize' /opt/app/vendor/bundle/ruby/2.3.0/gems/delayed_job-4.1.3/lib/delayed/lifecycle.rb:66:inexecute’
/opt/app/vendor/bundle/ruby/2.3.0/gems/delayed_job-4.1.3/lib/delayed/lifecycle.rb:40:in run_callbacks' /opt/app/vendor/bundle/ruby/2.3.0/gems/delayed_job-4.1.3/lib/delayed/worker.rb:173:inblock (2 levels) in start’
/opt/app/vendor/bundle/ruby/2.3.0/gems/delayed_job-4.1.3/lib/delayed/worker.rb:172:in loop' /opt/app/vendor/bundle/ruby/2.3.0/gems/delayed_job-4.1.3/lib/delayed/worker.rb:172:inblock in start’
/opt/app/vendor/bundle/ruby/2.3.0/gems/delayed_job-4.1.3/lib/delayed/plugins/clear_locks.rb:7:in block (2 levels) in <class:ClearLocks>' /opt/app/vendor/bundle/ruby/2.3.0/gems/delayed_job-4.1.3/lib/delayed/lifecycle.rb:79:inblock (2 levels) in add’
/opt/app/vendor/bundle/ruby/2.3.0/gems/delayed_job-4.1.3/lib/delayed/lifecycle.rb:61:in block in initialize' /opt/app/vendor/bundle/ruby/2.3.0/gems/delayed_job-4.1.3/lib/delayed/lifecycle.rb:79:inblock in add’
/opt/app/vendor/bundle/ruby/2.3.0/gems/delayed_job-4.1.3/lib/delayed/lifecycle.rb:66:in execute' /opt/app/vendor/bundle/ruby/2.3.0/gems/delayed_job-4.1.3/lib/delayed/lifecycle.rb:40:inrun_callbacks’
/opt/app/vendor/bundle/ruby/2.3.0/gems/delayed_job-4.1.3/lib/delayed/worker.rb:171:in start' /opt/app/vendor/bundle/ruby/2.3.0/gems/delayed_job-4.1.3/lib/delayed/tasks.rb:9:inblock (2 levels) in <top (required)>’
/opt/app/vendor/bundle/ruby/2.3.0/gems/rake-11.3.0/lib/rake/task.rb:248:in block in execute' /opt/app/vendor/bundle/ruby/2.3.0/gems/rake-11.3.0/lib/rake/task.rb:243:ineach’
/opt/app/vendor/bundle/ruby/2.3.0/gems/rake-11.3.0/lib/rake/task.rb:243:in execute' /opt/app/vendor/bundle/ruby/2.3.0/gems/airbrake-6.1.2/lib/airbrake/rake.rb:19:inexecute’
/opt/app/vendor/bundle/ruby/2.3.0/gems/rake-11.3.0/lib/rake/task.rb:187:in block in invoke_with_call_chain' /usr/local/lib/ruby/2.3.0/monitor.rb:214:inmon_synchronize’
/opt/app/vendor/bundle/ruby/2.3.0/gems/rake-11.3.0/lib/rake/task.rb:180:in invoke_with_call_chain' /opt/app/vendor/bundle/ruby/2.3.0/gems/rake-11.3.0/lib/rake/task.rb:173:ininvoke’
/opt/app/vendor/bundle/ruby/2.3.0/gems/rake-11.3.0/lib/rake/application.rb:152:in invoke_task' /opt/app/vendor/bundle/ruby/2.3.0/gems/rake-11.3.0/lib/rake/application.rb:108:inblock (2 levels) in top_level’
/opt/app/vendor/bundle/ruby/2.3.0/gems/rake-11.3.0/lib/rake/application.rb:108:in each' /opt/app/vendor/bundle/ruby/2.3.0/gems/rake-11.3.0/lib/rake/application.rb:108:inblock in top_level’
/opt/app/vendor/bundle/ruby/2.3.0/gems/rake-11.3.0/lib/rake/application.rb:117:in run_with_threads' /opt/app/vendor/bundle/ruby/2.3.0/gems/rake-11.3.0/lib/rake/application.rb:102:intop_level’
/opt/app/vendor/bundle/ruby/2.3.0/gems/rake-11.3.0/lib/rake/application.rb:80:in block in run' /opt/app/vendor/bundle/ruby/2.3.0/gems/rake-11.3.0/lib/rake/application.rb:178:instandard_exception_handling’
/opt/app/vendor/bundle/ruby/2.3.0/gems/rake-11.3.0/lib/rake/application.rb:77:in run' /opt/app/vendor/bundle/ruby/2.3.0/gems/rake-11.3.0/exe/rake:27:in<top (required)>’
/opt/app/vendor/bundle/ruby/2.3.0/bin/rake:23:in load' /opt/app/vendor/bundle/ruby/2.3.0/bin/rake:23:in<top (required)>’
/usr/local/bundle/gems/bundler-1.16.2/lib/bundler/cli/exec.rb:74:in load' /usr/local/bundle/gems/bundler-1.16.2/lib/bundler/cli/exec.rb:74:inkernel_load’
/usr/local/bundle/gems/bundler-1.16.2/lib/bundler/cli/exec.rb:28:in run' /usr/local/bundle/gems/bundler-1.16.2/lib/bundler/cli.rb:424:inexec’
/usr/local/bundle/gems/bundler-1.16.2/lib/bundler/vendor/thor/lib/thor/command.rb:27:in run' /usr/local/bundle/gems/bundler-1.16.2/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:ininvoke_command’
/usr/local/bundle/gems/bundler-1.16.2/lib/bundler/vendor/thor/lib/thor.rb:387:in dispatch' /usr/local/bundle/gems/bundler-1.16.2/lib/bundler/cli.rb:27:indispatch’
/usr/local/bundle/gems/bundler-1.16.2/lib/bundler/vendor/thor/lib/thor/base.rb:466:in start' /usr/local/bundle/gems/bundler-1.16.2/lib/bundler/cli.rb:18:instart’
/usr/local/bundle/gems/bundler-1.16.2/exe/bundle:30:in block in <top (required)>' /usr/local/bundle/gems/bundler-1.16.2/lib/bundler/friendly_errors.rb:124:inwith_friendly_errors’
/usr/local/bundle/gems/bundler-1.16.2/exe/bundle:22:in <top (required)>' /usr/local/bundle/bin/bundle:104:inload’
/usr/local/bundle/bin/bundle:104:in `’

This is my docker-compose.yml file:

version: '2'
services:
  web:
    build: .
    image: luftbild:latest
    mem_limit: 512m
    environment:
      - PASSENGER_MIN_INSTANCES=1
      - PASSENGER_MAX_POOL_SIZE=2
      - aws_access_key_id=mykey
      - aws_secret_access_key= mykey
      - CACHE_HOST=memcached
      - PATH=/opt/app/sphinx-3.0.3/bin:$PATH
    labels:
      - convox.deployment.minimum=50
      - convox.deployment.maximum=200
      - convox.port.80.protocol=http
      - convox.port.443.protocol=https
      - convox.health.path=/_health
      - convox.health.timeout=8
      - convox.idle.timeout=60
    ports:
      - "3000:3000"
    volumes:
      - ../lubimount/app:/opt/app
    command: [ "script/startup.sh", "web" ]
    links:
      - "memcached:11211"
  worker:
    build: .
    image: luftbild:latest
    mem_limit: 512m
    environment:
      - QUEUES=default,paperclip,mailers
      - MAGICK_MAP_LIMIT=64MiB
      - MAGICK_MEMORY_LIMIT=256MiB
      - MAGICK_TIME_LIMIT=30
      - aws_access_key_id= mykey
      - aws_secret_access_key= mykey
      - CACHE_HOST=memcached
    labels:
      - convox.deployment.minimum=0
      - convox.deployment.maximum=200
      # scheduled task definitions
      # Uncomment when deploying own installation of Sharetribe
      - convox.cron.test-task=0 9 * * ? bundle exec rails runner CommunityMailer.deliver_community_updates
    command: [ "script/startup.sh", "worker" ]
    links:
      - "memcached:11211"
  memcached:
    build: ./memcached
    image: memcached_img
    hostname: lubi-memcached

Thanks
Woppi

Hi @woppi

Permission denied @ rb_sysopen - /opt/app/db/sphinx/production/ts-listing_delta.tmp

Do you have the right access ?

Regards

Hi phatza,

i dont know how to give the script in the worker container access to the sphix service inside the web container, what was Sharetribes idea of the docker setup?

BR
Woppi