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_MAJOR "2.0"
ENV RUBY_VERSION "2.0.0-p643"
ENV RUBYGEMS_VERSION "2.5.2"
ENV BUNDLER_VERSION "1.11.2"
ENV NODE_VERSION "5.5.0"
ENV BOWER_VERSION "1.7.6"

ENV APT_PACKAGES " \
  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

WORKDIR /tmp
RUN curl -o ruby.tgz \
    "https://cache.ruby-lang.org/pub/ruby/${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 https://nodejs.org/dist/v${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/00_regen_ssh_host_keys.sh
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

EXPOSE 3000

COPY .conf_files/sidekiq.sh /etc/service/sidekiq/run
COPY .conf_files/appserver.sh /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:

  • Access docker within container on jenkins slave
  • Docker exec runs command on host machine instead of container
  • Docker image for windows with oracle12
  • How do you trace docker images brought in by a pull?
  • permission denied error in docker
  • Docker cannot resolve DNS on private network
  • #!/bin/bash
    
    SIDEKIQ_THREADS=${SIDEKIQ_THREADS:-16}
    cd /home/app/webapp
    
    exec chpst -u app bundle exec puma -C config/puma.rb \
              2>&1 |logger -t appserver
    SIDEKIQ_CONFIG="/home/app/webapp/config/sidekiq.yml"
    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?

  • pipelines fail with custom docker image
  • Run dockerised Flask app to heroku with gunicorn
  • can docker registry proxy support multiple remoteurl?
  • docker license &vm replacement
  • Why does the tag appear to be tightly coupled to hostname of the registry?
  • Managing Persistent Files (not database) with Docker
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.