【问题标题】:Pry Rails on docker not working在 docker 上撬 Rails 不工作
【发布时间】:2018-02-13 12:06:51
【问题描述】:

我尝试了在docker-compose.yml 中使用tty: true stdin_open: true 并附加到容器ID(在http://www.chris-kelly.net/2016/07/25/debugging-rails-with-pry-within-a-docker-container/ 之后)的方法,但它只是挂起。

我在这篇文章https://blog.carbonfive.com/2015/03/17/docker-rails-docker-compose-together-in-your-development-workflow/之后也尝试了docker-compose run --service-ports web,但是当binding.pry时它也会挂起请求

supervisord 会影响这个吗?

这是 Dockerfile:

FROM ruby:2.3.3

RUN apt-get update -qq && apt-get install -y build-essential libpq-dev supervisor
RUN curl -sL https://deb.nodesource.com/setup_9.x | bash - && apt-get install -yq nodejs
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 && apt-get install yarn


RUN mkdir /example
WORKDIR /example
COPY Gemfile /example/Gemfile
COPY Gemfile.lock /example/Gemfile.lock

RUN bundle install

COPY . /example
COPY docker/supervisor.conf /etc/supervisor/conf.d/example.conf

RUN cd client-app && npm install

CMD supervisord -n

还有docker-compose.yml

version: '3'
services:
db:
  image: postgres
web:
  build: .
  environment:
    API_HOST: http://localhost:3000/api
  volumes:
    - .:/example
  ports:
    - "3000:3000"
    - "4200:4200"
  depends_on:
    - db

还有supervisor.conf

[program:rails]
directory=/example
command=rails server -b 0.0.0.0 -p 3000
autostart=true
autorestart=true

[program:npm]
directory=/example
command=/bin/bash -c "yarn && cd client-app && npm run docker-start"
autostart=true
autorestart=true

【问题讨论】:

    标签: ruby-on-rails docker docker-compose pry pry-rails


    【解决方案1】:

    (假设您正在运行类似 docker run -d --name=postgres ... 的 postgres)

    我会放弃撰写并尝试

    docker build -t web .
    docker run --link postgres:db -it -p 3000:3000 -p 4200:4200 web
    

    如果失败了,我会踢球

    docker run --link postgres:db -it -p 3000:3000 -p 4200:4200 web bash
    

    然后尝试在容器中手动运行rails srails c 等。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-02-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多