FROM ruby:2.4.3
MAINTAINER BioSistemika <info@biosistemika.com>

# additional dependecies
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - && \
  apt-get update -qq && \
  apt-get install -y \
  nodejs \
  postgresql-client \
  netcat \
  default-jre-headless \
  sudo graphviz --no-install-recommends \
  libfile-mimeinfo-perl && \
  npm install -g yarn && \
  rm -rf /var/lib/apt/lists/*

ENV RAILS_ENV production

# install gems
COPY Gemfile* /usr/src/bundle/
COPY addons /usr/src/bundle/addons
WORKDIR /usr/src/bundle
RUN bundle install

# create app directory
ENV APP_HOME /usr/src/app
RUN mkdir $APP_HOME
WORKDIR $APP_HOME
COPY . .
RUN rm -f $APP_HOME/config/application.yml $APP_HOME/production.env

RUN DATABASE_URL=postgresql://postgres@db/scinote_production \
  PAPERCLIP_HASH_SECRET=dummy \
  SECRET_KEY_BASE=dummy \
  DEFACE_ENABLED=true \
  bash -c "rake assets:precompile && rake deface:precompile"

CMD rails s -b 0.0.0.0
