Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Commit

Permalink
Refactor how the Dockerfile is configured
Browse files Browse the repository at this point in the history
This will allow things to run on kubernetes with strict pod security
policies in place.

- Install all gems and binaries within /home/bandiera as the root user
- Run as an unprivileged user (id: 2000, name: bandiera)
- Remove some warnings when starting up puma
  • Loading branch information
dazoakley committed Nov 16, 2021
1 parent 944c9cb commit b265e7b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
9 changes: 5 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@ RUN apk update && \
update-ca-certificates && \
rm -rf /var/cache/apk/*

RUN addgroup bandiera && \
adduser -D -G bandiera -h /home/bandiera bandiera
RUN gem install bundler

WORKDIR /home/bandiera
RUN addgroup -S -g 2000 bandiera && \
adduser -S -u 2000 -D -G bandiera -h /home/bandiera bandiera

RUN gem install bundler
WORKDIR /home/bandiera

COPY Gemfile Gemfile
COPY Gemfile.lock Gemfile.lock

RUN bundle config set --local without 'test' && \
bundle config set --local deployment 'true' && \
bundle config set --local bin /home/bandiera/bin && \
bundle config set --local frozen 'true' && \
bundle install --jobs 4

Expand Down
8 changes: 1 addition & 7 deletions config/puma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,18 @@
require 'bandiera'

port = Integer(ENV['PORT'] || 5000)
unix_socket = ENV['SOCKET'] || '/tmp/bandiera.sock'

no_of_processes = Integer(ENV['PROCESSES'] || 1)
no_of_processes = Integer(ENV['PROCESSES'] || 0)
min_no_of_threads = Integer(ENV['MIN_THREADS'] || 8)
max_no_of_threads = Integer(ENV['MAX_THREADS'] || 32)

tag 'bandiera'
environment ENV['RACK_ENV'] || 'production'
worker_timeout 15

pidfile ENV['PID_FILE'] if ENV['PID_FILE']
state_path ENV['STATE_FILE'] if ENV['STATE_FILE']

threads min_no_of_threads, max_no_of_threads
workers no_of_processes

bind "tcp://0.0.0.0:#{port}"
bind "unix://#{unix_socket}"

preload_app!

Expand Down
8 changes: 6 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/bin/sh

bundle exec rake db:migrate
bundle exec puma
echo "Running database migrations..."
bin/rake db:migrate
echo "Database migrations complete."

echo "Starting up application..."
bin/puma -C config/puma.rb
2 changes: 1 addition & 1 deletion lib/bandiera/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Bandiera
VERSION = '4.0.0'
VERSION = '4.0.2'
end

0 comments on commit b265e7b

Please sign in to comment.