Skip to content

Instantly share code, notes, and snippets.

@daphsta
Created September 9, 2015 23:36
Show Gist options
  • Save daphsta/995e3ee96e977ca2a89a to your computer and use it in GitHub Desktop.
Save daphsta/995e3ee96e977ca2a89a to your computer and use it in GitHub Desktop.
Dockerfile for ruby/rails/mysql
# ---------------------------------------------------------------------------
# This is the Dockerfile to build the base image for ruby/rails/mysql
# ---------------------------------------------------------------------------
FROM debian:jessie
MAINTAINER XXX
ENV REFRESHED_AT 2015-08-07
# ---------------------------------------------------------------------------
# Using ruby-2.2.0
# ---------------------------------------------------------------------------
ENV RUBY_MAJOR 2.2
ENV RUBY_VERSION 2.2.0
# ---------------------------------------------------------------------------
# System and Ruby dependencies
# ---------------------------------------------------------------------------
ENV SYS_DEPS git curl procps autoconf build-essential libbz2-dev libcurl4-openssl-dev libffi-dev libssl-dev libreadline-dev libyaml-dev zlib1g-dev
ENV RUBY_DEPS bison ruby libmysqlclient-dev
# ---------------------------------------------------------------------------
# Install all dependencies, compile ruby and cleanup
# ---------------------------------------------------------------------------
RUN apt-get update \
&& apt-get install -y --no-install-recommends ${SYS_DEPS} ${RUBY_DEPS} \
&& mkdir -p /usr/src/ruby \
&& curl -SL "http://cache.ruby-lang.org/pub/ruby/$RUBY_MAJOR/ruby-$RUBY_VERSION.tar.bz2" | tar -xjC /usr/src/ruby --strip-components=1 \
&& cd /usr/src/ruby \
&& autoconf \
&& ./configure --disable-install-doc \
&& make -j"$(nproc)" \
&& apt-get purge -y --auto-remove bison ruby \
&& make install \
&& rm -r /usr/src/ruby \
&& rm -rf /var/lib/apt/lists/*
# ---------------------------------------------------------------------------
# Ensure timezone is present
# ---------------------------------------------------------------------------
RUN echo Australia/Brisbane > /etc/timezone && dpkg-reconfigure --frontend noninteractive tzdata
# ---------------------------------------------------------------------------
# Skip installing gem documentation
# ---------------------------------------------------------------------------
RUN echo 'gem: --no-rdoc --no-ri' >> "$HOME/.gemrc"
# ---------------------------------------------------------------------------
# Set the gem home, install bundler and configure it
# ---------------------------------------------------------------------------
ENV GEM_HOME /usr/local/bundle
ENV PATH $GEM_HOME/bin:$PATH
RUN gem update --system \
&& gem install bundler \
&& bundle config --global path "$GEM_HOME" \
&& bundle config --global bin "$GEM_HOME/bin" \
&& gem install foreman
# ---------------------------------------------------------------------------
# Don't create ".bundle" in all our apps
# ---------------------------------------------------------------------------
ENV BUNDLE_APP_CONFIG $GEM_HOME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment