FROM ruby:1.9.3

# Retrofit updates sources
RUN printf "deb http://archive.debian.org/debian/ jessie main\ndeb-src http://archive.debian.org/debian/ jessie main\ndeb http://security.debian.org jessie/updates main\ndeb-src http://security.debian.org jessie/updates main" > /etc/apt/sources.list

# Create working directory
RUN mkdir /app
WORKDIR /app

# Install postgres client required for Ruby gem and teh app itself
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev graphicsmagick graphicsmagick-imagemagick-compat

# Install Rails and Gems
COPY Gemfile* /app/
RUN bundle install

# Install Sphinx
COPY sphinxsearch_2.0.10-release-1~wheezy_amd64.deb /app/
RUN dpkg -i sphinxsearch_2.0.10-release-1~wheezy_amd64.deb

# App runner
COPY docker-start-cmd.sh /app/
CMD /app/docker-start-cmd.sh