Skip to content

Instantly share code, notes, and snippets.

@csexton
Last active February 17, 2016 02:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save csexton/9b2e75120fb7f23d7dae to your computer and use it in GitHub Desktop.
Save csexton/9b2e75120fb7f23d7dae to your computer and use it in GitHub Desktop.
Minimal Dockerfile for Alpine Linux, configurable Ruby version, no build tools, final image size about 200 M.
FROM alpine:3.3
MAINTAINER Christopher Sexton <chris@radiusnetworks.com>
ENV RUBY_VERSION 2.3.0
ENV RUBY_DOWNLOAD_SHA1 96e620e38af351c8da63e40cfe217ec79f912ba1
ENV BASE_PACKAGES bash curl gmp
ENV BUILD_PACKAGES build-base libc-dev linux-headers openssl-dev postgresql-dev libxml2-dev libxslt-dev
# Update and install all of the required packages.
# At the end, remove the apk cache
RUN apk update && \
apk upgrade && \
apk add $BASE_PACKAGES && \
rm -rf "/var/cache/apk/*"
RUN apk --update add --virtual build_deps $BUILD_PACKAGES && \
cd /tmp && \
wget -O ruby.tar.xz "https://cache.ruby-lang.org/pub/ruby/${RUBY_VERSION%.*}/ruby-$RUBY_VERSION.tar.xz" && \
echo "$RUBY_DOWNLOAD_SHA1 ruby.tar.xz" | sha1sum -c - && \
tar -xJf ruby.tar.xz && \
rm ruby.tar.xz && \
cd "/tmp/ruby-$RUBY_VERSION" && \
./configure --disable-install-doc && \
make && \
make install && \
rm -rf "/tmp/ruby-$RUBY_VERSION" && \
apk del build_deps && \
rm -rf "/var/cache/apk/*"
RUN gem install bundler --no-rdoc --no-ri
RUN mkdir /app
WORKDIR /app
COPY Gemfile /app/
COPY Gemfile.lock /app/
RUN bundle install
COPY . /app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment