Skip to content

Instantly share code, notes, and snippets.

@bonyiii
Created December 19, 2016 10:29
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 bonyiii/9e4bdff5617881be49f275b65a6c974d to your computer and use it in GitHub Desktop.
Save bonyiii/9e4bdff5617881be49f275b65a6c974d to your computer and use it in GitHub Desktop.
How to set up rails development with docker base image
# original idea taken from
# https://github.com/docker-library/redmine/blob/d564a3b0d78016b2f24af2d74bcdace26a1ac0a3/3.1/Dockerfile
FROM ruby:2.3
MAINTAINER Bonaventura Fleischmann <bonaventura.fleischmann@digitalnatives.hu>
# Add user whose name the app will be run within the container
# the user id should be the default first linux user id
RUN useradd -u 1000 dev
# install nodejs for execjs
RUN set -x \
&& curl -sL https://deb.nodesource.com/setup_7.x | bash -
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
wget \
openjdk-7-jre \
unzip \
imagemagick \
nodejs \
libmysqlclient18 \
libsqlite3-0 \
mysql-client \
git \
openssh-client \
&& rm -rf /var/lib/apt/lists/*
# grab gosu for easy step-down from root
ENV GOSU_VERSION 1.7
RUN set -x \
&& wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture)" \
&& wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture).asc" \
&& export GNUPGHOME="$(mktemp -d)" \
&& gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \
&& gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu \
&& rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc \
&& chmod +x /usr/local/bin/gosu \
&& gosu nobody true
# grab tini for signal processing and zombie killing
ENV TINI_VERSION v0.9.0
RUN set -x \
&& wget -O /usr/local/bin/tini "https://github.com/krallin/tini/releases/download/$TINI_VERSION/tini" \
&& wget -O /usr/local/bin/tini.asc "https://github.com/krallin/tini/releases/download/$TINI_VERSION/tini.asc" \
&& export GNUPGHOME="$(mktemp -d)" \
&& gpg --keyserver ha.pool.sks-keyservers.net --recv-keys 6380DC428747F6C393FEACA59A84159D7001A4E5 \
&& gpg --batch --verify /usr/local/bin/tini.asc /usr/local/bin/tini \
&& rm -r "$GNUPGHOME" /usr/local/bin/tini.asc \
&& chmod +x /usr/local/bin/tini \
&& tini -h
# Define commonly used JAVA_HOME variable
ENV JAVA_HOME /usr/lib/jvm/java-7-openjdk-amd64
# Switch to the user
USER dev
# Install asdf version manager for dev user
RUN git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.2.0 \
&& echo '. $HOME/.asdf/asdf.sh' >> ~/.bashrc \
&& echo '. $HOME/.asdf/completions/asdf.bash' >> ~/.bashrc
&& asdf plugin-add ruby https://github.com/asdf-vm/asdf-ruby.git \
&& asdf plugin-add nodejs https://github.com/asdf-vm/asdf-nodejs.git
# Switch back to root
USER root
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment