Docker Sidekiq Starting – Rails App with Puma

The following Dockerfile it’s supposed to start sidekiq when the container it’s started:

FROM phusion/baseimage:0.9.18

ENV RUBY_VERSION "2.0.0-p643"

  git imagemagick \
  gcc g++ make patch binutils libc6-dev \
  libjemalloc-dev libffi-dev libssl-dev libyaml-dev zlib1g-dev libgmp-dev \
  libxml2-dev libxslt1-dev libpq-dev libreadline-dev libsqlite3-dev htop \

ENV APT_REMOVE_PACKAGES "openssh-server"

RUN apt-get update && apt-get -y dist-upgrade
RUN apt-get install -y $APT_PACKAGES
RUN apt-get remove --purge -y $APT_REMOVE_PACKAGES
RUN apt-get autoremove --purge -y

RUN curl -o ruby.tgz \
    "${RUBY_MAJOR}/ruby-${RUBY_VERSION}.tar.gz" && \
  tar -xzf ruby.tgz && \
  cd ruby-${RUBY_VERSION} && \
  ./configure --enable-shared --with-jemalloc --disable-install-doc && \
  make -j4 && \
  make install && \
  rm /usr/local/lib/libruby-static.a

ENV GEM_SPEC_CACHE "/tmp/gemspec"
RUN echo 'gem: --no-document' > $HOME/.gemrc
RUN gem update --system ${RUBYGEMS_VERSION}
RUN gem install -v ${BUNDLER_VERSION} bundler

RUN curl${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.gz \
  |tar -xz -C /usr --strip-components=1
RUN npm install bower@${BOWER_VERSION} -g

RUN rm /etc/my_init.d/
RUN rm -r /etc/service/sshd

RUN useradd -m app
RUN mkdir /home/app/webapp && chown app:app -R /home/app

RUN rm -rf /tmp/* /var/tmp/* /var/lib/apt /var/lib/dpkg /usr/share/man /usr/share/doc

WORKDIR /home/app/webapp

# Copy the Gemfile as well as the Gemfile.lock and install
# the RubyGems. This is a separate step so the dependencies
# will be cached unless changes to one of those two files
# are made.
COPY Gemfile Gemfile.lock ./
RUN gem install bundler && bundle install --jobs 20 --retry 5 --without development test

# Copy the main application.
COPY . ./

COPY .cron/daily_run_app /etc/cron.daily/
RUN chmod a+x /etc/cron.daily/daily_run_app

# Precompile Rails assets
RUN bundle exec rake assets:precompile


COPY .conf_files/ /etc/service/sidekiq/run
COPY .conf_files/ /etc/service/appserver/run

# Start puma
RUN chmod a+x /etc/service/appserver/run
ENTRYPOINT /etc/service/appserver/run

#ENTRYPOINT bundle exec puma -C config/puma.rb
# Start sidekiq
#ENTRYPOINT bundle exec sidekiq -L log/sidekiq.log
#RUN chmod a+x /etc/service/sidekiq/run
#ENTRYPOINT /etc/service/sidekiq/run

The script /etc/service/appserver/run:

  • How to warmup application inside Docker Container?
  • Docker exposing ports madness
  • Run Fluentd Docker Image as Non Root
  • AWS Mesosphere: parameters for docker daemon
  • What is a correct/better way to use docker stack deploy with independently updated services?
  • xdebug in phpstorm and docker
  • #!/bin/bash
    cd /home/app/webapp
    exec chpst -u app bundle exec puma -C config/puma.rb \
              2>&1 |logger -t appserver
    exec chpst -u root bundle exec sidekiq -t 5 -c $SIDEKIQ_THREADS -C $SIDEKIQ_CONFIG \
        2>&1 |logger -t sidekiq

    You can enquequed jobs because you can see that in the sidekiq dasboard, but they are not going to be processed because sidekiq it’s not started, but it should be started with the Dockerfile and Script that are shown above. So when you type manually:

    bundle exec sidekiq

    Right here sidekiq it’s started and the jobs now could be processed. what could be happening?

  • Docker image > google/cadvisor:latest
  • Symfony environment in Docker container
  • What is the best practices of using Docker for front end development on OS X and passthrough ENV from host to container
  • Connecting to percona docker from a java docker container
  • Re-introduced “Unknown initial character set index” error?
  • Should Swarm Master Join As Node in a Single Node Cluster?
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.