Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

more information on how debugging a rails container is hard? #2

Open
noahpatterson opened this issue Jan 8, 2015 · 1 comment
Open

Comments

@noahpatterson
Copy link

You mentioned it was difficult to develop and debug rails in a container, do you have any blog links that talk about this?

Thanks!

@jhirn
Copy link
Contributor

jhirn commented Jan 12, 2015

Sorry I don't know of any blogs that talk about this specifically but I can tell you what I find inconvenient about running the app itself from within a container.

  • I need full env locally for executing tests. Also consider editor integration for test execution. Can't see this being easy at the moment.
  • I also need this for running rails console.
  • I rely heavily on debugging with pry. Not sure how this works when it's ran from within container but if it involves remote debugger, it's already more complicated.

I did recently do this to run sidekiq workers from within a container because those are mostly background but I then discovered another issue. Every time the Gemfile is modified you need to rerun bundle install via fig build and the prior layer isn't cached, so it's a clean bundle install (2-5 minutes depending on, well, bundler). I plan to blog about that soon but this is the Dockerfile and fig.yml I used:

sidekiq:
  build: .
  working_dir: /my_app
  command: bundle exec sidekiq
  environment:
    - DOCKER_IP
  volumes:
    - .:/my_app
  links:
    - db
    - redis
FROM ubuntu-debootstrap:trusty
MAINTAINER Joe Hirn <[email protected]>

RUN locale-gen en_US.UTF-8

ENV HOME /root
ENV PATH $HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH
ENV SHELL /bin/bash
ENV LANG en_US.UTF-8
ENV LC_ALL en_US.UTF-8
ENV RBENV_ROOT $HOME/.rbenv
RUN apt-get -q update \
  && DEBIAN_FRONTEND=noninteractive apt-get -q -y install wget autoconf bison build-essential libssl-dev libyaml-dev zlib1g-dev git \
  && apt-get -q clean \
  && apt-get autoremove -y

RUN git clone https://github.com/sstephenson/rbenv.git $RBENV_ROOT \
  && mkdir -p $RBENV_ROOT/plugins \
  && git clone https://github.com/sstephenson/ruby-build.git $RBENV_ROOT/plugins/ruby-build \
  && echo 'eval "$(rbenv init -)"' >> $HOME/.profile \
  && echo 'eval "$(rbenv init -)"' >> $HOME/.bashrc

# APP specific

ENV RUBY_VERSION 2.1.5

RUN rbenv install $RUBY_VERSION \
  && rbenv global $RUBY_VERSION \
  && gem install --no-ri --no-rdoc bundler \
  && rbenv rehash

RUN apt-get -y install libcurl4-openssl-dev libpq-dev nodejs

RUN mkdir /my_app
WORKDIR /my_app
ADD Gemfile Gemfile
ADD Gemfile.lock Gemfile.lock
RUN bundle -j4 && rbenv rehash

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants