动作电缆不适用于docker部署

时间:2019-01-10 12:21:03

标签: ruby-on-rails nginx docker-compose actioncable

我的Ruby on Rails 5应用出现问题。 在开发过程中一切正常,但是当我在服务器上使用docker部署(ubuntu 16 LTS)时,操作电缆不起作用。

我关注了这些芭蕾舞短裙:

这是我的文件:

  • docker-compose.yml

        Error: Error trying to start business network. Error: No valid responses from any peers.
    Response from attempted peer comms was an error: Error: 2 UNKNOWN: error starting container: Failed to generate platform-specific docker build: Error returned from build: 1 "npm ERR! code EAI_AGAIN
    npm ERR! errno EAI_AGAIN
    npm ERR! request to https://registry.npmjs.org/composer-common failed, reason: getaddrinfo EAI_AGAIN registry.npmjs.org:443
    
    npm ERR! A complete log of this run can be found in:
    npm ERR!     /root/.npm/_logs/2019-01-10T11_49_13_667Z-debug.log
    "
    Command failed
    
  • 我的Dockerfile

    
    version: '3'
    services:
      db:
        image: postgres:9.6
        environment:
          - ACIM_DATABASE_PASSWORD=ACIM_2018
        volumes:
          - 'db:/var/lib/postgresql/data'
        env_file:
          - '.env'
        expose:
          - '5432'
        ports:
          - "7000:5432"
      nginx: 
        image: nginx:latest
        container_name: production_nginx
        volumes:
          - ./config/nginx/nginx.conf:/etc/nginx/nginx.conf
          - public-content:/var/www/acim/public
        ports:
          - 80:80
          - 443:443
        links:
        - web
    
      # maildev:
      #   image: djfarrelly/maildev
      #   ports:
      #     - "2000:80"
    
      redis:
        image: redis
        command: redis-server
        volumes:
          - 'redis:/data'
        ports:
          - "6379"
    
      sidekiq:
        build: .
        #command: sidekiq -C config/sidekiq.yml
        command: bundle exec sidekiq
        volumes:
          - .:/ACIM
        links:
          - db
          - redis
        depends_on:
          - db
          - redis
        env_file:
          - '.env'
      web:
        build: .
        command: bundle exec rails s -p 3000 -b '0.0.0.0'
        volumes:
          - bundle_cache:/bundle
          - public-content:/var/www/acim/public
          - .:/ACIM
        ports:
          - "5000:3000"
        depends_on:
          - db
          - redis
        env_file:
          - '.env'
    
      cable:
        depends_on:
          - 'redis'
        build: .
        command: puma -p 28080 cable/config.ru
        ports:
          - '28080:28080'
        volumes:
          - '.:/ACIM'
        env_file:
          - '.env'
    
    volumes:
      bundle_cache:
      redis:
      db:
      public-content:
    
    • 我的NGINX文件

    FROM ruby:2.5.1
    
    # Install dependencies
    RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
    
    ENV RAILS_ROOT /var/www/acim/public
    RUN mkdir -p $RAILS_ROOT
    RUN mkdir -p $RAILS_ROOT/log
    RUN rm -rf /var/www/acim/public/tmp/pids/server.pid
    
    # Set working directory, where the commands will be ran:
    WORKDIR $RAILS_ROOT
    
    # Setting env up
    ENV RAILS_ENV='production'
    ENV RACK_ENV='production'
    
    # Adding gems
    COPY Gemfile Gemfile
    COPY Gemfile.lock Gemfile.lock
    RUN bundle install --jobs 20 --retry 5 --without development test
    
    # Adding project files
    COPY . .
    RUN bundle exec rake assets:precompile
    
    EXPOSE 3000
    CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"]
    
  • 我的config / environements / production.rb

    user www-data;
    worker_processes 4;
    pid /run/nginx.pid;
    
    events {
        worker_connections 768;
        # multi_accept on;
    }
    
    http {
    
        ##
        # Basic Settings
        ##
    
        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        # server_tokens off;
    
        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;
    
        include /etc/nginx/mime.types;
        default_type application/octet-stream;
    
        ##
        # Logging Settings
        ##
    
        # access_log /var/log/nginx/access.log;
        # error_log /var/log/nginx/error.log;
    
        upstream acim {
            server 192.168.99.100:5000;
        }
    
        server {
        listen 0.0.0.0;
        server_name 192.168.99.100;
    
        root /var/www/acim/publc;
    
        # define where Nginx should write its logs
        # access_log /var/www/acim/log/nginx.access.log;
        # error_log /var/www/acim/log/nginx.error.log;
    
        try_files $uri/index.html $uri @app;
    
        location / {
            proxy_pass http://acim;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $http_host;
            proxy_redirect off;
        }
    
        location /assets/ {
            expires 1y;
            add_header Cache-Control public;
            add_header ETag "";
            root /var/www/acim/public/public;
        }
    
        location /cable {
            proxy_pass http://192.168.99.100:28080;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_set_header Host $host;
        }
        location /redis {
            proxy_pass http://192.168.99.100:6379;
        }
    
        error_page 500 502 503 504 /500.html;
        client_max_body_size 4G;
        keepalive_timeout 10;
      }
    }
    
    

这是chrome开发工具的标签网络[WS]的输出。 chrome developper tool-> network -> ws

你能帮我吗? 谢谢

0 个答案:

没有答案