Skip to content

Commit

Permalink
Merge pull request #47 from maxfierke/mf-update_docker_container
Browse files Browse the repository at this point in the history
Rebuild Docker image as a lighter weight alpine image w/ Ruby 2.6.5
  • Loading branch information
ssgelm authored Jan 8, 2020
2 parents 5c252c7 + 8b4331f commit afadc2a
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.9.3-p194
2.6.5
64 changes: 48 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,52 @@
FROM debian:stretch
FROM debian:buster-slim

EXPOSE 9293/TCP
EXPOSE 9294/TCP
WORKDIR /home/litmus_paper
RUN apt-get update && apt-get install -y ruby ruby-dev git curl rsyslog build-essential
RUN gem install --no-ri --no-rdoc bundler \
&& gem install sinatra --no-ri --no-rdoc --version "~> 1.3.2" \
&& gem install remote_syslog_logger --no-ri --no-rdoc --version "~> 1.0.3" \
&& gem install unicorn --no-ri --no-rdoc --version "~> 4.6.2" \
&& gem install colorize --no-ri --no-rdoc \
&& gem install rspec --no-ri --no-rdoc --version "~> 2.9.0" \
&& gem install rack-test --no-ri --no-rdoc --version "~> 0.6.1" \
&& gem install rake --no-ri --no-rdoc --version "~> 0.9.2.2" \
&& gem install rake_commit --no-ri --no-rdoc --version "~> 0.13"
ADD . /home/litmus_paper
RUN ln -sf /home/litmus_paper/docker/litmus.conf /etc/litmus.conf \
&& ln -sf /home/litmus_paper/docker/litmus_unicorn.rb /etc/litmus_unicorn.rb

ENV APP_USER litmus_paper
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8

RUN apt-get update && apt-get install -y --no-install-recommends \
ruby \
ruby-dev \
bundler \
git \
curl \
rsyslog \
procps \
build-essential \
&& rm -rf /var/lib/apt/lists/*

# Create non-root user
RUN addgroup --gid 1000 --system $APP_USER && \
adduser --uid 1000 --ingroup $APP_USER --system $APP_USER

ENV GEM_HOME /usr/local/bundle
ENV BUNDLE_APP_CONFIG $GEM_HOME
ENV PATH $GEM_HOME/bin:$PATH

ADD litmus_paper.gemspec /home/$APP_USER/
ADD lib/litmus_paper/version.rb /home/$APP_USER/lib/litmus_paper/version.rb
ADD Gemfile* /home/$APP_USER/

WORKDIR /home/$APP_USER

RUN bundle config --global frozen 1 && \
bundle install \
-j2 \
--retry 3 \
# Remove unneeded files (cached *.gem, *.o, *.c)
&& rm -rf /usr/local/bundle/cache/*.gem \
&& find /usr/local/bundle/gems/ -name "*.c" -delete \
&& find /usr/local/bundle/gems/ -name "*.o" -delete

ADD . /home/$APP_USER
RUN ln -sf /home/$APP_USER/docker/litmus.conf /etc/litmus.conf \
&& ln -sf /home/$APP_USER/docker/litmus_unicorn.rb /etc/litmus_unicorn.rb
RUN gem build litmus_paper.gemspec && gem install litmus_paper*.gem
RUN chown -R $APP_USER:$APP_USER /home/$APP_USER

# Drop to app user
USER $APP_USER

CMD ["bin/litmus", "-p", "9293", "-c", "/etc/litmus_unicorn.rb"]
2 changes: 1 addition & 1 deletion docker/litmus.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
port 9292
port 9293
data_directory '/tmp/litmus_paper'
cache_location '/tmp/litmus_paper_cache'
cache_ttl -1
Expand Down
3 changes: 0 additions & 3 deletions docker/litmus_unicorn.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
# vim: set ft=ruby
require 'remote_syslog_logger'

APP_ROOT = '/var/lib/gems/2.3.0/gems/litmus_paper-1.1.1'

worker_processes 5
working_directory APP_ROOT

logger(RemoteSyslogLogger.new('127.0.0.1', 514, :program => 'litmus_paper', :facility => 'daemon'))

Expand Down

0 comments on commit afadc2a

Please sign in to comment.