У меня есть приложение Rails 3, которое зависит от private_pub . В моей попытке Dockerize это приложение, кажется, все работает, как ожидалось, кроме моего контейнера Faye. Я знаю, что мое приложение может подключиться к контейнеру, но, похоже, Faye не может опубликовать sh.
Ошибка:
undefined method `empty?' for nil:NilClass
Трассировка стека:
private_pub (1.0.3) lib/private_pub.rb:37:in `publish_message'
config/initializers/private_pub_override.rb:3:in `publish_to'
app/controllers/application_controller.rb:137:in `update_current_user_request_timeout'
activesupport (3.2.22.5) lib/active_support/callbacks.rb:484:in `_run__1519331844239038619__process_action__209294035435723309__callbacks'
activesupport (3.2.22.5) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.22.5) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
activesupport (3.2.22.5) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.22.5) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.2.22.5) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (3.2.22.5) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.2.22.5) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.22.5) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.22.5) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.22.5) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.2.22.5) lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
activerecord (3.2.22.5) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (3.2.22.5) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.2.22.5) lib/abstract_controller/rendering.rb:46:in `process'
actionpack (3.2.22.5) lib/action_controller/metal.rb:203:in `dispatch'
actionpack (3.2.22.5) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.2.22.5) lib/action_controller/metal.rb:246:in `block in action'
actionpack (3.2.22.5) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
actionpack (3.2.22.5) lib/action_dispatch/routing/route_set.rb:36:in `call'
journey (1.0.4) lib/journey/router.rb:68:in `block in call'
journey (1.0.4) lib/journey/router.rb:56:in `each'
journey (1.0.4) lib/journey/router.rb:56:in `call'
actionpack (3.2.22.5) lib/action_dispatch/routing/route_set.rb:608:in `call'
actionpack (3.2.22.5) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.4.7) lib/rack/etag.rb:23:in `call'
rack (1.4.7) lib/rack/conditionalget.rb:25:in `call'
actionpack (3.2.22.5) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.2.22.5) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.2.22.5) lib/action_dispatch/middleware/flash.rb:242:in `call'
rack (1.4.7) lib/rack/session/abstract/id.rb:210:in `context'
rack (1.4.7) lib/rack/session/abstract/id.rb:205:in `call'
actionpack (3.2.22.5) lib/action_dispatch/middleware/cookies.rb:341:in `call'
activerecord (3.2.22.5) lib/active_record/query_cache.rb:64:in `call'
activerecord (3.2.22.5) lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
actionpack (3.2.22.5) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (3.2.22.5) lib/active_support/callbacks.rb:405:in `_run__1246919101591079304__call__533293211663241495__callbacks'
activesupport (3.2.22.5) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.22.5) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
activesupport (3.2.22.5) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.22.5) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (3.2.22.5) lib/action_dispatch/middleware/reloader.rb:65:in `call'
actionpack (3.2.22.5) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
better_errors (2.5.1) lib/better_errors/middleware.rb:59:in `call'
actionpack (3.2.22.5) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.22.5) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.22.5) lib/rails/rack/logger.rb:32:in `call_app'
railties (3.2.22.5) lib/rails/rack/logger.rb:16:in `block in call'
activesupport (3.2.22.5) lib/active_support/tagged_logging.rb:22:in `tagged'
railties (3.2.22.5) lib/rails/rack/logger.rb:16:in `call'
request_store (1.4.1) lib/request_store/middleware.rb:19:in `call'
actionpack (3.2.22.5) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.7) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.7) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.22.5) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.7) lib/rack/lock.rb:15:in `call'
actionpack (3.2.22.5) lib/action_dispatch/middleware/static.rb:83:in `call'
railties (3.2.22.5) lib/rails/engine.rb:484:in `call'
railties (3.2.22.5) lib/rails/application.rb:231:in `call'
rack (1.4.7) lib/rack/content_length.rb:14:in `call'
railties (3.2.22.5) lib/rails/rack/log_tailer.rb:17:in `call'
thin (1.7.2) lib/thin/connection.rb:86:in `block in pre_process'
thin (1.7.2) lib/thin/connection.rb:84:in `catch'
thin (1.7.2) lib/thin/connection.rb:84:in `pre_process'
thin (1.7.2) lib/thin/connection.rb:53:in `process'
thin (1.7.2) lib/thin/connection.rb:39:in `receive_data'
eventmachine (1.2.7) lib/eventmachine.rb:195:in `run_machine'
eventmachine (1.2.7) lib/eventmachine.rb:195:in `run'
thin (1.7.2) lib/thin/backends/base.rb:73:in `start'
thin (1.7.2) lib/thin/server.rb:162:in `start'
rack (1.4.7) lib/rack/handler/thin.rb:13:in `run'
rack (1.4.7) lib/rack/server.rb:268:in `start'
railties (3.2.22.5) lib/rails/commands/server.rb:70:in `start'
railties (3.2.22.5) lib/rails/commands.rb:55:in `block in <top (required)>'
railties (3.2.22.5) lib/rails/commands.rb:50:in `tap'
railties (3.2.22.5) lib/rails/commands.rb:50:in `<top (required)>'
script/rails:6:in `require'
script/rails:6:in `<main>'
Я немного нуб, когда дело доходит до Docker. Я полагаю, что все правильно подключил, и я попытался следовать этому решению , но в итоге получил тот же результат.
Я создал Docker Hub image для Фэй.
Вот мой Dockerfile:
FROM ruby:2.3.8
RUN apt-get update -qq && apt-get install -y
# Setup path
ENV APP_PATH .
# Create dir
RUN mkdir /faye
WORKDIR /faye
RUN gem install faye private_pub thin
COPY ${APP_PATH}/private_pub.ru /faye/private_pub.ru
COPY ${APP_PATH}/private_pub.yml /faye/private_pub.yml
CMD ["rackup", "private_pub.ru", "-s", "thin", "-E", "production", "-o", "0.0.0.0"]
Вот мой docker -compose.yml:
version: '3'
services:
db:
image: mariadb
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: 1
MYSQL_DATABASE: round_three_development
volumes:
- db_data:/var/lib/mysql
- ./docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
faye:
image: jforgue/faye
ports:
- "9292:9292"
web:
build:
context: .
dockerfile: docker/Dockerfile
command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
volumes:
- .:/round-three-docker
ports:
- "3000:3000"
depends_on:
- db
- faye
volumes:
db_data: { driver: local }
Я почти уверен, что это ошибка сети, но я не могу найти, где я ошибся.