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:

  • docker container exited immediately after python script execution
  • What is the difference between Docker Swarm and Kubernetes/Mesophere?
  • Consul running on Docker HTTP health check returns “connection reset by peer”
  • Override FROM image's ENV in Dockerfile
  • Can't Ping a Pod after unbuntu cluster setup
  • Postgres networking with Docker containers and host LAN
  • #!/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?

  • How to reach docker containers by name instead of IP address?
  • kairosdb service not starting in container
  • rails docker app bundle rake aborted
  • Does Kubernetes evenly distribute across an ec2 cluster?
  • Adding an ECS instance in AWS - where to set the cluster name
  • Does anyone know a docker image that contains The MySQL Test Framework, Version 2.0?
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.