Skip to content

Instantly share code, notes, and snippets.

@mirlisboa
Forked from colby-swandale/Rails DockerFile
Created February 7, 2021 23:46
Show Gist options
  • Save mirlisboa/353d2649118cf7b521e2498aa5aa72f4 to your computer and use it in GitHub Desktop.
Save mirlisboa/353d2649118cf7b521e2498aa5aa72f4 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