Tag: ruby on rails

docker-compose rails应用程序在使用时找不到数据库,但是在运行时没有find数据库

我有一个简单的Rails应用程序,我试图运行使用Docker。 当我运行docker-compose up它运行,但是当我加载一个页面,它告诉我,我的数据库不存在。 即使当我运行docker-compose run app rails db:create它说db已经存在。 泊坞窗,compose.yml version: '2' services: db: image: postgres app: build: ./rails command: bundle exec rails s -p 3000 -b '0.0.0.0' volumes: – ./app:/app ports: – "3000:3000" depends_on: – db ./rails/Dockerfile FROM ruby:2.3.3 RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs RUN mkdir /app WORKDIR /app […]

Rails – 使用Phusion Passenger在Docker容器内部启用Nginx

在我的应用程序中启用https时遇到问题。 我设法使其不用ssl工作,但在尝试了其他教程后,似乎没有为我工作。 我会尽量保持代码简短,并分享最重要的部分。 Dockerfile FROM phusion/passenger-customizable RUN apt-get update && apt-get install -y \ dialog \ net-tools \ build-essential \ wget \ libpq-dev \ git \ nginx nginx-extras\ rsync \ bzip2 \ && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* RUN rm -f /etc/service/nginx/down RUN rm /etc/nginx/sites-enabled/default ADD config/nginx/nginx.conf /etc/nginx/sites-enabled/nginx.conf ADD config/nginx/fullchain.pem /etc/nginx/ssl/fullchain.pem ADD […]

将Docker容器中的rails应用程序通过URL连接到外部Postgresql数据库

我有一个networking导轨应用程序的docker容器。 另外我在我的OSX机器上有外部数据库。 如果我在osx上执行: psql "postgres://postgres:testing@0.0.0.0:5432/movies_development" 我跑得好 如果我在容器中运行,我会收到 psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"? 有任何想法如何从容器连接到外部数据库? 谢谢

在Docker中使用structure.sql中的模式运行`rails db:setup`

我有一个新的Rails应用程序,我打算在一个Docker容器中进行部署。 我们正在使用structure.sql而不是schema.rb 。 在我的本地设置(使用docker-compose文件,在Postgres在一个单独的容器中),当我运行rails db:setup ,出现以下错误: rails aborted! failed to execute: psql -q -f /rails/db/structure.sql cappy_dev Please check the output above for any errors and make sure that `psql` is installed in your PATH and has proper permissions. /usr/local/bundle/gems/activerecord-5.0.2/lib/active_record/tasks/postgresql_database_tasks.rb:99:in `run_cmd' /usr/local/bundle/gems/activerecord-5.0.2/lib/active_record/tasks/postgresql_database_tasks.rb:71:in `structure_load' /usr/local/bundle/gems/activerecord-5.0.2/lib/active_record/tasks/database_tasks.rb:213:in `structure_load' /usr/local/bundle/gems/activerecord-5.0.2/lib/active_record/tasks/database_tasks.rb:226:in `load_schema' /usr/local/bundle/gems/activerecord-5.0.2/lib/active_record/tasks/database_tasks.rb:253:in `block in load_schema_current' /usr/local/bundle/gems/activerecord-5.0.2/lib/active_record/tasks/database_tasks.rb:292:in `block in each_current_configuration' /usr/local/bundle/gems/activerecord-5.0.2/lib/active_record/tasks/database_tasks.rb:291:in […]

使用docker与RDS(Prod),但困惑本地数据库设置(开发)

我正在devise一个使用Docker的Rails web应用程序,出于各种原因,为了可configuration性和持久性的目的,我想在Production环境中使用RDS,而不是基于Docker容器的数据库(这是必需的)。 我意识到我可以将database.ymlconfiguration为指向我的Prod env的RDS实例,以及本地开发环境中的某个本地数据库实例。 然而,我很困惑是否在我的本地开发环境中使用基于容器的数据库,或者像MySQL服务器这样的外部数据库。 基于env-agnostic容器的Docker模式,我想在一些envs中只有一个基于容器的数据库没有任何意义(事实上,我不认为docker-compose.yml甚至会支持这样的东西),所以我假设我将需要去我的本地开发环境的MySQL服务器解决scheme。 有没有人通过这样的要求? 让我知道,如果我正在考虑这个正确的方式。 另外,这是否会对数据库迁移脚本造成任何潜在的问题? 任何build议,欢迎! 谢谢。

Sidekiq使用redis的不正确的URL

我build立了我的Docker环境,并试图让sidekiq与我的其他服务一起使用docker docker-compose up ,但是sidekiq在尝试连接到错误的 redis URL时抛出一个错误: redis_1 | 1:M 19 Jun 02:04:35.137 * The server is now ready to accept connections on port 6379 sidekiq_1 | Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED) 我相当有信心,在我的Rails应用程序中没有引用将有Sidekiq连接到本地主机,而不是docker-compose.yml中创build的redis服务: version: '3' services: db: image: postgres web: build: . command: bundle exec rails s -p 3000 -b '0.0.0.0' volumes: – .:/app […]

Rails 5应用程序连接到Docker + Puma(Nginx)+ PostgreSQL

我已经看过一些教程,但不能设置,只是如我所愿。 我有一些Rails应用程序,我不想放置在Docker容器中,因为它使诸如运行任务或迁移等事情有点令人讨厌。 不过,我想将这些应用程序连接到Nginx(使用Rails 5的默认Puma服务器)和使用Docker的PostgreSQL容器。 什么是正确的方法来设置呢? 这甚至有可能吗? 我正在考虑如下内容: app1 app2 app3 \ | / \ | / \ | / \ | / ——– |Docker| ——– ======= ============ |Nginx| |PostgreSQL| ======= ============ 提前致谢!

在dockerized Rails 5应用上启动Capybara-Webkit

我正在开发全新的Rails 5应用程序,而且我无法启动Capybara-Webkit。 我遵循这些迹象 。 我的开发过程包括Docker-Compose,然后是CircleCI,用于构buildDocker镜像并将其发送到Google Cloud Registry。 $ bundle install , $ docker build已经完成,但是我甚至无法使用Webkit在本地启动规范。 当我启动这个命令时,它会挂起并冻结: $ docker-compose run web xvfb-run -a bundle exec rspec 我找不到任何关于xvfb-run命令的许多信息,我假设它是一个包装在xvfb中的启动程序。 这是我的Dockerfile: FROM ruby:2.4.1 RUN apt-get update -qq && apt-get install -y \ build-essential \ libpq-dev \ nodejs \ xvfb \ qt5-default \ libqt5webkit5-dev \ gstreamer1.0-plugins-base \ gstreamer1.0-tools \ gstreamer1.0-x RUN […]

无法从其他Docker容器访问在一个Docker容器中运行的MS SQL

我在Docker中运行MS SQL 我可以从我的工作站访问MS SQL,但是如果尝试从我的导轨docker容器进行连接,则无法工作: $ docker exec -it 73 bundle exec rails c Loading development environment (Rails 5.1.3) [1] pry(main)> User.last TinyTds::Error: Cannot open server 'mssql' requested by the login. Client with IP address '109.74.176.74' is not allowed to access the server. To enable access, use the Windows Azure Management Portal or run sp_set_firewall_rule on […]

Mongo DB:消息超出了允许的最大消息大小

¡嗨! 我刚开发的RoR应用程序与MongoDB一起工作,并正常工作。 我尝试了几个HTTP请求到邮递员的应用程序,也工作得很好! 当我使用Docker部署应用程序时,出现了任何请求之后出现的MongoDB错误: MONGODB | 消息超出了允许的最大消息大小 最大值是50331648. ms_notifications_1 | 2017-09-29 21:16:48 +0000:HTTPparsing错误,格式错误request():#Puma :: HttpParserError:HTTP格式无效,parsing失败。 我会很感激如果有人有这个错误的解决scheme。 谢谢! 我的撰写文件: version: '2' services: ms_notifications_db: image: mongo:latest container_name: "rancher-node1" ` environment: – MONGO_DATA_DIR=/data/db – MONGO_LOG_DIR=/dev/null volumes: – ./data/db:/data/db ports: – "27017:27017" command: mongod –smallfiles ` ms_notifications: build: . command: bash -c " rm -f tmp/pids/server.pid && bundle exec […]