Skip to content

Instantly share code, notes, and snippets.

@colby-swandale
Created October 25, 2015 08:56
Show Gist options
  • Save colby-swandale/234a5193f58e140acec9 to your computer and use it in GitHub Desktop.
Save colby-swandale/234a5193f58e140acec9 to your computer and use it in GitHub Desktop.
Dockerfile with rbenv and ruby-install
FROM ubuntu:latest
MAINTAINER Colby Swandale <colby@taplaboratories.com.au>
# update apt cache and install dependencies
RUN apt-get update && apt-get install git curl build-essential libssl-dev libreadline-dev zlib1g-dev sqlite3 libsqlite3-dev -y
# add app user
RUN adduser --gecos '' --disabled-password app
# set user to app
USER app
# set rbenv, ruby-build bin paths
ENV HOME /home/app
ENV PATH $HOME/.rbenv/shims:$HOME/.rbenv/bin:$HOME/.rbenv/plugins/ruby-build/bin:$PATH
# clone rbenv
RUN git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
# clone ruby-build
RUN git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
# set working directory to project src
WORKDIR /src
# add Gemfile, Gemfile.lock, .ruby-version to docker
ADD Gemfile Gemfile.lock .ruby-version ./
# install ruby
RUN rbenv install
# install bundler
RUN gem install bundler
# install app dependencies
RUN bundle install
# run rails
CMD ["bundle", "exec", "rails", "server"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment