Properly build Puma, and other native gems, inside the container

This doesn't end up as big as I feared, so I'm rather pleased.

Fixes #3
This commit is contained in:
R. Tyler Croy 2017-09-03 17:27:18 -07:00
parent 9e8a768e11
commit ce0ba7e520
No known key found for this signature in database
GPG Key ID: 1426C7DC3F51E16F
4 changed files with 20 additions and 9 deletions

View File

@ -1,13 +1,12 @@
FROM ruby:2.3-alpine
ARG BUILD_PKGS="ruby-dev openssl-dev gcc make libc-dev binutils"
ARG APP_DIR=/webapp
RUN mkdir -p ${APP_DIR}/vendor
WORKDIR ${APP_DIR}
ADD vendor/ ${APP_DIR}/vendor/
ENV GEM_HOME=${APP_DIR}/vendor/gems
ENV BUNDLE_PATH=${APP_DIR}/vendor/gems
ENV BUNDLE_APP_CONFIG=${APP_DIR}/vendor/gems/.bundle
@ -18,4 +17,10 @@ ADD app/ ${APP_DIR}/app/
ADD config.ru ${APP_DIR}/
ADD views ${APP_DIR}/views/
ADD assets ${APP_DIR}/assets/
CMD bundle exec rackup -o 0.0.0.0
RUN apk add -U ${BUILD_PKGS} && \
bundle install && \
apk del ${BUILD_PKGS} && \
rm -rf /var/cache/apk/*
CMD bundle exec puma

View File

@ -1,10 +1,11 @@
source 'https://rubygems.org'
gem 'haml'
gem 'sinatra'
gem 'httparty'
gem 'puma'
gem 'sentry-raven'
gem 'sentry-api'
gem 'httparty'
gem 'sinatra'
group :test do
gem 'rspec'

View File

@ -17,6 +17,7 @@ GEM
multi_xml (0.6.0)
multipart-post (2.0.0)
mustermann (1.0.1)
puma (3.10.0)
rack (2.0.3)
rack-protection (2.0.0)
rack
@ -51,6 +52,7 @@ PLATFORMS
DEPENDENCIES
haml
httparty
puma
rspec
sentry-api
sentry-raven

View File

@ -1,16 +1,19 @@
all: check container
check: depends spec
check: spec check-container
spec:
spec: depends
./scripts/ruby bundle exec rspec -c
depends: Gemfile
./scripts/ruby bundle install
run: depends
./scripts/ruby bundle exec rackup -o 0.0.0.0
./scripts/ruby bundle exec puma
check-container: container
docker run --rm rtyler/codevalet-canary:latest bundle exec puma --version
container: depends Dockerfile
docker build -t rtyler/codevalet-canary .
@ -18,4 +21,4 @@ container: depends Dockerfile
clean:
rm -rf vendor
.PHONY: all depends clean run check container spec
.PHONY: all depends clean run check container spec check-container