From ce0ba7e52050cfa2244a3751275d1446fd563318 Mon Sep 17 00:00:00 2001 From: "R. Tyler Croy" Date: Sun, 3 Sep 2017 17:27:18 -0700 Subject: [PATCH] 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 --- Dockerfile | 11 ++++++++--- Gemfile | 5 +++-- Gemfile.lock | 2 ++ Makefile | 11 +++++++---- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 959dbba..e41e227 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/Gemfile b/Gemfile index 0bfcb9e..299b793 100644 --- a/Gemfile +++ b/Gemfile @@ -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' diff --git a/Gemfile.lock b/Gemfile.lock index 47be6f9..0e0ebb6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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 diff --git a/Makefile b/Makefile index 40e461a..de3c721 100644 --- a/Makefile +++ b/Makefile @@ -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