# Source: https://github.com/spree/spree/blob/master/Dockerfile

# Builds Spree at v4.1.12 tag and allows CORS requests

FROM ruby:2.5.1
RUN apt-get update -qq && \
  apt-get install -y build-essential libpq-dev && \
  curl -sL https://deb.nodesource.com/setup_8.x | bash - && apt-get install -y nodejs
WORKDIR /spree

RUN apt-get install -y git
RUN git clone https://github.com/spree/spree.git .
RUN git checkout tags/v4.1.12

RUN bundle install
RUN bundle exec rake sandbox
WORKDIR /spree/sandbox
RUN bundle add rack-cors
ADD config/application.rb config/_application_custom.rb
RUN cat config/_application_custom.rb >> config/application.rb

WORKDIR /spree

CMD ["sh", "docker-entrypoint.sh"]