Tag: ruby on rails

两个docker集装箱如何相互通信?

我有两个容器,想互相沟通。 容器'A'包含在端口5432上的PostgreSQL数据库的discourse.org应用程序,容器'B'具有运行在端口1000上的ROR应用程序。我想与ROR应用程序build立数据库连接到PostgreSQL(在另一个容器中)。 如何连接ROR应用程序与PostgreSQL数据库? RoR应用程序,docker-compose.yml version: '2' services: app: build: . command: bundle exec rails s -p 9000 -b '0.0.0.0' volumes: – ".:/slackcron" ports: – "9000:9000" RoR应用程序,database.yml development: <<: *default database: discourse username: muzammil password: '123' host: 0.0.0.0 port: 5432 docker工人 CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 92a9cb961e56 slackcroncom_app "bundle exec rails…" 47 seconds […]

Rails,Webpacker和Docker:不能分配请求的地址 – 连接(2)为:3035

我正在尝试使用webpacker , puma 3.10.0 , rails 5.1.4和webpacker 3.0.1 。 我为docker设置了以下configuration: Dockerfile FROM ruby:2.4.1 ENV DIR=/app \ BUNDLE_JOBS=4 RUN curl -sL https://deb.nodesource.com/setup_7.x | bash – RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add – RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs openssl yarn RUN […]

如果一个服务在docker build期间启动,它应该在运行时运行吗?

我一直在努力在单个容器中设置一个独立的导轨应用程序。 这意味着同时在一个容器中同时运行rails和数据持久性服务。 在我们的例子中,这意味着MySQL。 但是,我遇到了多个问题得到这个工作,因为MySQL没有运行。 在构build步骤中,如果我RUN mysqld ,然后单独RUN rake db:create step,则rake将会崩溃,因为mysql已closures。 所以我通过将这两个命令包装到一个脚本中来解决这个问题。 但是,在运行时,rails将无法启动,因为mysql没有运行。 我的直觉说,如果在构build期间启动mysql,它应该在运行时可用,但我没有那种经验。 启动rails服务器必须用另一个mysqld调用包装在一个脚本中。 这里是dockerfile: FROM ruby:2.2 RUN mkdir -p $APPDIR WORKDIR $APPDIR ADD Gemfile* $APPDIR/ RUN bundle install RUN apt-get update -qq RUN DEBIAN_FRONTEND=noninteractive apt-get install -y -qq nodejs mysql-server –no-install-recommends RUN rm -rf /var/lib/apt/lists/* # */ broken syntax highlighting COPY . $APPDIR RUN […]

在Docker下放置.gitignore文件的位置?

我正在处理我的第一个包含rails应用程序的docker-compose.yml。 我应该如何处理.gitignore文件? 在主目录中我有: 泊坞窗,compose.yml README.md 加上每个非图像容器的文件夹 我在相关的容器目录中生成了一个Rails应用程序。 这包括标准生成的.gitignore文件。 我应该将.gitignore移动到主目录,并将所有忽略保留在一个地方,或者将它留在原来的位置,并将忽略保留在容器目录级别 。 有没有我没见过的陷阱?

Docker-compose – Redis在0.0.0.0而不是127.0.0.1

我将我的Rails应用程序(本地开发机器)迁移到Docker-Compose。 除了Worker Rails实例(批处理)无法连接到Redis以外,所有工作都正常。 Completed 500 Internal Server Error in 40ms (ActiveRecord: 2.3ms) Redis::CannotConnectError (Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED)): 在我的docker-compose.yml中 redis: image: redis ports: – "6379:6379" batch: build: . command: bundle exec rake environment resque:work QUEUE=* volumes: – .:/app links: – db – redis environment: – REDIS_URL=redis://redis:6379 我认为Redis实例通过Docker主机的IP可用。 $ docker-machine ls NAME ACTIVE DRIVER […]

Docker无法使用postgresql安装rails

我是docker工人。 我尝试用docker安装我的rails应用程序。 我使用postgresql的数据库。 我用这个无花果。 当我跑步 fig run web rake db:create 我得到错误"could not connect to server: Connection refused Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432?"." 任何帮助将不胜感激。 提前致谢

Ruby:捕获Sequel :: DatabaseConnectionError

我使用Docker来运行我的Ruby应用程序,并将MySQL作为数据库。 我需要我的Ruby应用程序等到MySQL完成加载并build立连接。 我使用下面的代码: def connect_to_db begin puts "Trying to connect to Mysql" Sequel::Model.db = Sequel.connect( // Connection stuff in here ) rescue Sequel::Error => e puts "Mysql connection failed #{e.message}: Retrying." retry end end connect_to_db() 这运行一次,然后我得到一个错误 – Sequel::DatabaseConnectionError: Mysql2::Error: Unknown MySQL server host (25) – 它不会进入rescue块,不会重试。 我已经尝试了rescue Sequel::DatabaseConnectionError但是这给出了相同的结果。 我需要在这里拯救什么?

Docker与rake资源组合 – 构build – 预编译

我试图设置我的应用程序在生产模式下运行,我遇到了一个问题,build立资产文件夹,特别是我的Dockerfile中的这一行: RUN bundle exec rake RAILS_ENV=production DATABASE_URL=postgresql://user:pass@127.0.0.1/dbname SECRET_TOKEN=dummytoken assets:precompile 数据库只是一个虚拟的行。 问题是,当它运行耙子似乎没有看到envvariables,并得到以下错误时,它初始化carrierwave.rb rake aborted! ArgumentError: Missing required arguments: aws_access_key_id, aws_secret_access_key /usr/local/bundle/gems/fog-core-1.42.0/lib/fog/core/service.rb:244:in `validate_options' /usr/local/bundle/gems/fog-core-1.42.0/lib/fog/core/service.rb:268:in `handle_settings' /usr/local/bundle/gems/fog-core-1.42.0/lib/fog/core/service.rb:98:in `new' /usr/local/bundle/gems/fog-core-1.42.0/lib/fog/core/services_mixin.rb:16:in `new' /usr/local/bundle/gems/fog-core-1.42.0/lib/fog/storage.rb:27:in `new' /usr/local/bundle/gems/carrierwave-0.11.2/lib/carrierwave/uploader/configuration.rb:83:in `eager_load_fog' /usr/local/bundle/gems/carrierwave-0.11.2/lib/carrierwave/uploader/configuration.rb:96:in `fog_credentials=' /mnt/hgfs/Projects/livingrecipe/config/initializers/carrierwave.rb:3:in `block in <top (required)>' /usr/local/bundle/gems/carrierwave-0.11.2/lib/carrierwave/uploader/configuration.rb:118:in `configure' /usr/local/bundle/gems/carrierwave-0.11.2/lib/carrierwave.rb:14:in `configure' /mnt/hgfs/Projects/livingrecipe/config/initializers/carrierwave.rb:1:in `<top (required)>' Theres多了几条线,但第一行说这一切和ENVvariables的aws_access_key_id和aws_secret_access_key似乎不会加载。 如果我运行这个没有试图预编译资产一切正常,但我需要预编译的资产,使其可见的nginx 我确实发现,为了解决这个问题,我可以用它们replaceENVvariables,这是有问题的代码: CarrierWave.configure do |config| config.fog_credentials = { provider: […]

Docker撰写:Rails将不尊重DATABASE_URL连接到Postgres

我试图容器化我的Ruby on Rails的5.1.0应用程序,但我有一些麻烦,不从环境中拿DATABASE_URL 。 在docker-compose.yml ,我有以下服务: app: build: . command: bundle exec rails s -p 3000 -b '0.0.0.0' volumes: – .:/myapp environment: DATABASE_URL: postgres://postgres:pw@db:5432/myapp_development 如果我运行docker-compose run app rails c : $ docker-compose run app rails c Running via Spring preloader in process 25 Loading development environment (Rails 5.1.0) irb(main):001:0> ENV['DATABASE_URL'] => "postgres://postgres:pw@db:5432/myapp_development" 但是,如果我运行docker-compose run app […]

Rails MSSQL – TinyTds ::错误:Adaptive Server连接超时

我想尝试让我们的CI工具CircleCI中的Rails和MSSQL交谈。 我在Mac上工作,所以设置这个是相当痛苦的。 我使用Homebrew在本地安装了FreeTDS。 然后,我产生了一个MSSQL泊坞窗图像,并在我的Rails应用程序中设置我的configuration指向它,这一切工作。 CircleCI有点不同。 我做了以下。 在我的gemfile中添加: # mssql database gems gem 'tiny_tds' gem 'activerecord-sqlserver-adapter' 修改我们的database.yml文件: default: &default adapter: sqlserver pool: 5 encoding: utf8 mode: dblib development: <<: *default host: localhost database: collections_development username: sa password: P@55w0rd test: <<: *default host: localhost database: collections_test username: sa password: P@55w0rd 我build立了一个docker形象: FROM circleci/ruby:2.4.1-node-browsers RUN set -ex \ […]