FROM docker.internal.justin.tv/devtools/bionic/ruby2.5.1:latest

COPY ./scripts/download-maxmind.sh /tmp/twitch/adminpanel/scripts/download-maxmind.sh

ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get install -y tzdata
RUN apt-get update && apt-get install -y bison flex nodejs zlib1g-dev && \
    wget https://github.com/Yelp/dumb-init/releases/download/v1.2.1/dumb-init_1.2.1_amd64.deb && \
    dpkg -i dumb-init_*.deb 

RUN ["/bin/bash", "-c", ". /tmp/twitch/adminpanel/scripts/download-maxmind.sh -f GeoIP2-City.mmdb -u && . /tmp/twitch/adminpanel/scripts/download-maxmind.sh -f GeoIP2-ISP.mmdb -u"]

COPY . /target

WORKDIR /target

RUN bundle install --jobs 10 --retry 2 --deployment --without development && \
    RAILS_ENV=test bundle exec rake assets:clean && \
    RAILS_ENV=test bundle exec rake assets:precompile

ENTRYPOINT ["/usr/bin/dumb-init", "--"]
