FROM ruby:2.4-alpine
MAINTAINER Marien Fressinaud <dev@marienfressinaud.fr>

EXPOSE 3000 5000

WORKDIR /app/

RUN apk add --no-cache \
      nodejs \
      postgresql-client \
      tzdata \
  && npm install npm@5 -g
RUN apk --update add --virtual build-dependencies \
      build-base \
      ruby-dev \
      openssl-dev \
      postgresql-dev \
      libc-dev \
      linux-headers \
      cmake \
      gmp-dev

COPY Gemfile Gemfile.lock /app/
RUN gem install bundler \
  && bundle install \
  && apk del build-dependencies

COPY client/package.json client/package-lock.json /app/client/
RUN cd /app/client \
  && npm install \
  && npm cache clean --force

VOLUME /app

CMD ["bundle", "exec", "foreman", "start"]
